Doco Home Tools Home

Platypus Tools - Presentation and Business Layers Interface

Methods

Platypus defines a number of methods within the business layer that the presentation layer may call upon. The definitions allow Billabong and Pond to autogenerate the methods to be called as well as the actual call to the method. Some of these methods are available to the presentation layer from any business object, while others might be restricted to the business object for this presentation object or the 'common' directory (e.g. reports).

Business objects that accessible by the presentation layer are called 'POBOs' for convenience. In general, the aim within Platypus is to have the presentation layer deal with Strings only. This allows a reduction in complexity for the presentation layer and helps the separation of presentation and business logic in the application.

The methods defined for autogeneration are:

  • public PulldownItem[] getPulldownItems(String pulldown_name) throws ApplicationException

    A pulldown may also be known as a select menu or option selector. It's based on the HTML <SELECT> and <OPTION> tags. The name passed is the ID to the SELECT tag. This method is available from all POBOs.

  • public int get[ACCESS_NAME]([ACCESS_PARAMS]) throws ApplicationException

    The ACCESS_NAME is a query name. This name is defined in the PO.x.ACCESSES section in the configuration file for this particular presentation object. The presentation layer can invoke a query, passing the parameters listed in ACCESS_PARAMS to the method. Note that the parameters passed will all be of type String. The number of records found in the query is the return value. A particular get[ACCESS_NAME] method is generated for the POBO associated with a presentation layer object.

  • public String getIdValue(int index, String id, String format) throws ApplicationException

    This method is used after calling a get[ACCESS_NAME] method. The index refers to a row within the query results and therefore must range between 0 and the number of results minus one. The id string must match an id used in the configuration file for this presentation object. The format value indicates how the data is to be formatted for the presentation layer, e.g. converting a number to monetary format, etc. This method is available from all POBOs, however if the id passed is not known to a particular BO (or perhaps hasn't been coded yet), then a debug result string is returned. During development, these debug result strings can be useful.

  • public String getIdValue(String oidstr, String id, String format) throws ApplicationException

    This method is very similar to the getIdValue(int index, ...) method above, however it can be called without a previous call to a get[ACCESS_NAME] method. The oidstr passed is an Object Id that refers to a row in the table of interest. The id and format are the same as above. Again, this method is available from all POBOs and the above caveat on ids still applies.

  • public String commit[COMMIT_NAME]([COMMIT_PARAMS]) throws ApplicationException

    The commit[COMMIT_NAME] method allows the presentation layer to provide data to the business layer for adding or updating records. The COMMIT_NAME is defined in the PO.x.COMMITS section in the configuration file for the presentation object. The COMMIT_PARAMS are String values supplied by the presentation layer. The responsibility of data conversion and checking is handled by the business layer. The value returned is the Object Id, as a String, of the new or updated record.

  • public String getBusinessIdValue(String id, String format) throws ApplicationException and
    public void setBusinessIdValue(String id, Object data) throws ApplicationException

    These methods provide two way access between the business and presentation layer. The business layer can provide 'arbitrary' information to the presentation layer, e.g. today's date formatted correctly for the locale, or perhaps the results of an LDAP query. The latter example may require the use of the setBusinessIdValue to perhaps provide the LDAP query to invoke. The id values in these methods give the business layer developer some clues to the appropriate actions to be coded.

  • Data Formatting

    A number of the methods above have a format parameter. Platypus provides a class called FormatUtil that handles formatting data for display. This allows the business layer to handle data in numerous types, e.g. dates, numbers, etc. and format it appropriately as a String for the presentation layer. Normally, if the data is extracted from the database, the business layer uses the data's type internally for processing and only converts to a String for the presentation layer.

    For details on the formats available and how to use them, refer to the FormatUtil.java file in the src/production directory of the distribution.

    FormatUtil also contains a number of methods to convert data from presentation layer display strings back to data usable by the data layer. In version 1.0, this is limited to date related methods.

    Note that there is no restriction on the presentation layer directly calling the FormatUtil class. In the Platypus tutorial, there are examples of this in a few files.