This is the syntax reference for spiralcraft.servlet.webui specific template tags
The spiralcraft.webui syntax extends the spiralcraft.textgen syntax, adding components common to developing interactive web user interfaces as well as additional sets of components geared to different front-end types (ie. HTML, RPC)
Components common to all web user interfaces
Examples assume the following namespace mapping:
<%@namespace webuic="class:/spiralcraft/servlet/webui/components/" %>
Used by components to interact with the request query string.
A RequestBinding is not a markup element itself, so it can only be instantiated as a property value for another object or element.
This example will read the URI query variable "id" and assign it to the "MySessionType.fooId" property, automatically converting it from a String to the appropriate property type. If the variable is not found in the URI, a null value will be assigned to the property. The property will be automatically published in self-links generated within this page.
<%webui.DataSessionComponent%>
<%.requestBindings%>
<%webuic:RequestBinding
name="id"
target="[mySessions:MySessionType].fooId"
passNull="true"
publish="true"
/%>
<%/.requestBindings%>
<%/webui.DataSessionComponent%>
The following will read the request URI query variable named "inputdata", pass it to the static method MyCustomType.parse(String input) in the package referenced by the "mytypes" namespace, and will assign the resulting value to the property "MySessionType.fooId". If the query variable was not found in the URI, a value of null will be assigned to the property.
<%webui.DataSessionComponent%>
<%.requestBindings%>
<%webuic:RequestBinding
name="inputdata"
target="[mySessions:MySessionType].fooId = [@mytypes:MyCustomType].@parse(.)"
passNull="true"
/%>
<%/.requestBindings%>
<%/webui.DataSessionComponent%>
This example is equivalent to example 1, except the the conversion from a String to the type of the "MySessionType.fooId" property is handled by the MyStringConverter class, which must extend the "spiralcraft.util.string.StringConverter" superclass.
<%webui.DataSessionComponent%>
<%.requestBindings%>
<%webuic:RequestBinding
name="id"
target="[mySessions:MySessionType].fooId"
passNull="true"
publish="true"
%>
<%.converter%>
<%myTypes:MyStringConverter
foo="xyz"
/%>
<%/.converter%>
<%/webuic:RequestBinding%>
<%/.requestBindings%>
<%/webui.DataSessionComponent%>
| name | String | The query variable name | ||
| target | Expression<?> | The binding target. The type of the expression target is auto-converted from a String via the spiralcraft.util.string auto-conversion mechanism. If the expression is an assignment, the right hand side can reference the input String as the telescoped Focus subject (ie. "." reference). | ||
| passNull | boolean | Whether to set the model location to null if the variable is not present in the query string | ||
| publish | boolean | Whether to register this parameter to be added to URLs in <%Link%> tags, <%Form%> actions, and other actions- elements intended to capture a user response to the current page state. |
||
| converter | StringConverter | Supply custom logic to convert from Strings to native types (see spiralcraft.util.string auto-conversion mechanism). Incoming and outgoing data will be encoded/decoded from a URL-encoded representation to a java.lang.String automatically- this object must not concern itself with HTTP/HTML encoding. |
Provides a session-scoped buffer cache used for Form based data editing, along with an optional session-scoped data object to store page level state (eg. query parameters, model state, workflow, etc.,.)
This object is visible within the context of a single WebUI resource.
<%webuic:DataSessionComponent typeX="[@mySessions:MySessionType].type" %> ... page code ... <%/webuic:DataSessionComponent%>
| typeURI | java.net.URI | Optional. A URI for a spiralcraft.data.Type to load for the page state. | ||
| typeX | Expression<spiralcraft.data.Type> | Optional. A spiralcraft.data.Type for the local page state. Using typeX is an alternative to typeURI, and is also useful when the DataSessionComponent needs to resolve its type contextually. |
Redirects to a specified URI when an optional condition holds.
<%webuic:Redirect redirectURI="/index.webui" when="[mySessions:MySession].foo == null" /%>
| redirectURI | java.net.URI | Where to redirect. | ||
| when | Expression<Boolean> | Optional. The condition that must return true. If omitted, the resource will always redirect. |
| locationX | Expression<String> | Dynamic redirect location. |
Components for building HTML specific user interfaces.
Examples assume the following namespace mapping:
<%@namespace html="class:/spiralcraft/servlet/webui/components/html/" %>
Components that emit HTML tags normally use tag renderers, accessible through the "tag" and "errorTag" properties of the component. The tag renderer generally has a set of properties which conform to HTML 4.0 common attributes plus anything specific to the particular tag. Developers can specify values for these attributes which will be transparently encoded and rendered with the tag.
<%html:Form%> ...content and controls <%/html:Form%>
<select ... > control (drop-down menu) sourced from an iterable model component, that binds the user selection to a model target.
<option ... > element to display select list item and indicate selected item and return value.
<%html:Select
x="myBindingTarget"
source="myListData"
%>
<%html:Option value="myListDataBoundField"%>
<%=optionDisplayExpr/%>
<%/html:Option%>
<%/html:Select%>
<input type="image" ... > control, bound to a command.
<%html:ImageButton x="commandExpression" src="xyz.jpg" tag.alt="Alt Text" tag.height="10" tag.width="10" tag.border="0" /%>