To support using GPO within JSP a number of custom tags are provided.
These have been designed to make iniitialization and access to the GPO system
as simple as possible, and in conjunction with the Alchemist system generation
dramatically simplifies the amount of code that needs to be written.
The normal java initialization using OMClient and derived classes is support by the
gpo:init tag, that can be used as follows:
<%@ taglib uri="/tags/gpo" prefix="gpo" %> <gpo:init store='/db/test.rw' />
For Alchemist generated systems the derived client class should be provided:
<%@ taglib uri="/tags/gpo" prefix="gpo" %> <gpo:init clientClass='alchemy.contacts.client.ContactsClient' store='/db/test.rw' />
This stores the client in the application context, and opens the associated
database.
The optional parameters are as follows:
| parameter | Description |
|---|---|
| clientClass | The OMClient derived class |
| om | Specific IObjectManager implementation |
| store | Specific store file |
| desc | Xml description file |
The OMClient provides a method to getDefaultRoot that by default
returns the NameManager used to remember and recall
keyed values. The Alchemist generated OMClient specializations
will return the root object of the defiend model.
<%@ taglib uri="/tags/gpo" prefix="gpo" %> <gpo:root> <%= root.toString() %> </gpo:root>
The single optional id parameter supports the specification of variable name:
<gpo:root id='myRoot'> <%= myRoot.toString() %> </gpo:root>
Accessing the GPO objects is the base requirement for any GPO
based application. The gpo tag provides just that - either from an
explicit object reference - gpoId or a parameter in the
current request:
<%@ taglib uri="/tags/gpo" prefix="gpo" %> <gpo:gpo id='gpo' parameter='id'> <h2>Inspect <%=gpo.getID()%></h2> </gpo:metaSpec>
...or:
<gpo:gpo id='gpo' gpoId='12'> <h2>Inspect <%=gpo.toString()%></h2> </gpo:metaSpec>
When browsing a GPO model, the MetaSpec object can provide a generic
protocol to discover key aspects of the target object.
The metaspec tag provides access to the MetaSpec object either from a provided
src GPO object or via an external parameter.
<%@ taglib uri="/tags/gpo" prefix="gpo" %> <gpo:metaSpec id='metaSpec' parameter='id'> <h2>Inspect <%=metaSpec.getLabel()%></h2> </gpo:metaSpec>
Alternatively, the metaSpec tag can be nested within a gpo tag:
<%@ taglib uri="/tags/gpo" prefix="gpo" %>
<gpo:gpo parameter='id'>
<gpo:metaSpec id='metaSpec'>
<h2>Inspect <%=metaSpec.getLabel()%></h2>
</gpo:metaSpec>
</gpo:gpo>
The remember and recall tags support the IObjectManager
protocol to remember and recall values.
These can be used straightforwardly to persistently retain certain values:
<%@ taglib uri="/tags/gpo" prefix="gpo" %> <gpo:remember key='name' value='Cut The Crap'/>
To recall you must provide the key and the id
of the variable. Optionally you can provide the type of the data to avoid
any casting in your code.
<%@ taglib uri="/tags/gpo" prefix="gpo" %> <gpo:recall id='name' key='name' type='java.lang.String'> <h2>Length of name is <%=name.length()%></h2> </gpo:recall>
An additional option controls the scope of the variable created, although it will
default to nested if a scope='page' is declared the variable will be
available to any script following the start tag.