Tag reference

This section outlines each of the available tags showing what attributes they support and gives examples of their use.

action-button

Creates an empty form with just a button that invokes the specified method when pressed, forwarding the results to the specified view.

action-button attributes

Name Description Required Default
object Identifier for a specific object, or a service identifier prefixed by "service:". no RESULT
method Method on the object or service to invoke when the user presses the submit button. yes
view View to be forwarded to after submission and an object is returned. no _generic.html
void View to be forwarded to after submission and no object is returned. no _generic.html
result-name Name of variable to store the resultant object. no RESULT
scope How long the variable should be kept for. no request
title Title for the submission button. no the action's name

The action-button element can contain one or more parameter elements.

The following example creates an HTML form with no visible fields and a button that invokes the myRecentClaims method on the claims services when the button is pressed.

<swf:action-button object="service:Claims" method="myRecentClaims" />

See also: Link, Link and Link

action-form

Creates a form with entry fields for each of the action's parameters. When the user presses the submit button the action will be invoked, if all the parameter are valid, and the result forwarded to the specified page. If the parameters are invalid control will be forwarded to the specified error page.

If the specified action is not visible or usable no form will be displayed.

action-form attributes

Name Description Required Default
object Identifier for a specific object, or a service identifier prefixed by "service:". no RESULT
method Method on the object or service to invoke when the user has provided the necessary parameters in the generated form and has pressed the submit button. yes
view View to be forwarded to after submission and an object is returned. no _generic.html
void View to be forwarded to after submission and no object is returned. no _generic.html
error View to be forwarded to after validation failure prevents the action from being invoked. no _generic.html
result-name Name of variable to store the resultant object. no RESULT
scope How long the results variable should be kept for. no request
title Title for the submission button. no "OK"
legend Title for the generated form. no the action's name

The action-form element can contain one or more of the following elements

The following example creates an HTML form that will provide fields for each of the parameters of the createNewClaim method on the claims service. When the submit button is pressed the method will be invoked with the provided fields and the generic form will be used (as no view attribute was specified) to display the result.

<swf:action-form object="service:Claims" method="createNewClaim" />

See also: Link, Link and Link

action-link

Creates a hyper-link that will run the specified method, when the user clicks the link, and will forward the result to the specified view. This tag should only be used for actions that do not change the state of the system as hyper-links are for accessing information not processing data.

action-link attributes

Name Description Required Default
object Identifier for a specific object, or a service identifier prefixed by "service:". no RESULT
method Method on the object or service to invoke when the user clicks the link. yes
view View to be forwarded to after the method has be executed. no the current page
result-name Name of variable to store the resultant object. no RESULT
scope How long the variable should be kept for. no request
confirm To be implemented - not in use yet! no

The action-link element can contain one or more parameter elements

The following example creates a hyper-link of the text "Show All Recent Claims", and will execute the method myRecentClaims on the claims service when the user clicks on it.

<swf:action-link object="service:Claims" method="myRecentClaims">Show All Recent Claims</swf:action-link>

See also: Link, Link and Link

action-name

Provides the name of the specified action on an object or service. This will be name derived from the method or a proper name added to the method via the programming model. Additionally, if the system is set to internationalized the name and descriptions then the returned name will be the localized version.

action-name attributes

Name Description Required Default
object Identifier for a specific object, or a service identifier prefixed by "service:". yes
method Method on the object or service to find the name for. yes

The following example finds the name for the createNewExpenseItem method on the object reference by the claim variable.

<swf:action-name object="${claim}" method="createNewExpenseItem" />

collection

The collection element iterates over a collection outputting the contents of the contained block for each element in the collection.

collection attributes

Name Description Required Default
collection Identifier for a specific collection. If the field attribute is set then the collection will be ignored. no RESULT
object Identifier for a specific object. no RESULT
field Name of the field to get the collection from within the specified object. no
element-name The name of the variable to assign the rows object ID to when the row is selected. no RESULT

The collection element can contain one or more of the following

  • text
  • HTML elements
  • scimpi elements

The following example creates an HTML table by creating a row for each element in the collection. The collection that is being used is from the items field in the claim object as referenced by the claim variable. The current element is stored in the variable entry.

<table>
  <swf:collection object="${claim}" field="items" element-name="item">
    <tr>
      <td><swf:field object="${item}" field="date" /></td>
      <td<swf:field object="${item}" field="description" ="180" /></td>
      <td><swf:field object="${item}" field="amout" /></td>
    </tr>
  </swf:collection>
<table>

See also: Link, Link and Link

content

The content element marks the point within a template file (see Link) where the generated content will be placed when it is produced. This element is only processed when a template element is being processed, and should only occur with a template file.

debug

Inserts debug details into the page.

debug attributes

Name Description Required Default
object Identifier of object to display no
variable Name of variable no
value Literal value no
list list the variables, parameters or mappings. no

The following example displays all the variables held by the context for the request, interaction, session and also globally.

<swf:debug list="variables" />

See also: Link and Link

diagnostics

Displays some basic diagnostic information, such as the URI and set variables, when debug flag is set. To set the debug flag append &debug=on to a URL, to turn off append &debug=off.

See also: Link and Link

edit

Creates a form with a set of fields for the properties of an object and a button that updates the object with the entered values.

edit attributes

Name Description Required Default
object Identifier for a specific object. no RESULT
view View to be forwarded to after submission. no _generic.html
error View to be forwarded to if any field does not validate. no the current page
title Title for the submission button. no Save
legend Title for the generated form. no
result-name Name of variable to store the edited object. no RESULT
scope How long the variable should be kept for. no request

The edit element can contain one or more of the following elements

The following example creates a simple edit form for a claimant that does not include the normal approver field.

<swf:edit object="${claimant}" view="my-claims.html">
    <swf:exclude field="normalApprover" />
</swf:edit>

edit-link

Creates a hyper-link to a specified object edit page with the specified object embedded in the URL.

edit-link attributes

Name Description Required Default
object Identity of the object to be passed on to the view. no RESULT
view View to be forwarded to. no _generic_edit.html
param-name Name of parameter to pass the object identifier across as. no RESULT

The edit-link element can contain one or more of the following elements

  • text
  • HTML elements

The following example creates a hyper-link to the page edit-me.html, passing across the identifier for the current object as it does so.

<swf:edit-link view="edit-me.html">Edit claimant</swf:object-link>

See also: Link and Link

element-type

Retrieves the type of element that a collection holds.

element-type attributes

Name Description Required Default
collection Identifier for a specific collection. If the field attribute is set then the collection will be ignored. no RESULT
object Identifier for a specific object. no RESULT
field Name of the field to get the collection from within the specified object. no

The following example gets the type of element that the claimant's items collection holds.

<swf:element-type object="${claimant}" field="items"/>

exclude

Marks a field so that it will not be displayed when displaying a form or table etc.

exclude attributes

Name Description Required Default
name Name of the field to be excluded yes

The exclude element can be placed within following elements

The following example would produce a form that shows all the properties except for the contact from the current object.

<swf:short-form>
  <swf:exclude name="contact"/>
</swf:short-form>

See also: Link and Link

feedback

Displays both collected warnings and messages

See also: Link and Link

field

Retrieves the title of the field within a specified object.

field attributes

Name Description Required Default
object Identifier for a specific object. no RESULT
field Name of the field to be displayed. yes
icon If icon is set to "true", "yes" or "on" an icon will also be displayed as well as the text. If set to "false", "no" or "off" no Icon will be shown. no yes
truncate Limit the text to a specified number of characters. If set to 0 then no truncation occurs. no 0

See also: Link

form-field

Adds the enclosed block alongside the field in an edit or action form.

field attributes

Name Description Required Default
field Name of the field/parameter to be placed with. yes

The following example adds in an HTML select widget (a drop down) that has the three options: alpha, beta and gamma. When the user selects one of the options from the drop-down the grade property will be set with that value.

<swf:edit object="${claimant}">
    <swf:form-field field="grade">
         <select name="grade">
              <option>alpha</option>
              <option>beta</option>
              <option>gamma</option>
         </select>           
    <swf:form-field/>
</swf:edit>

See also: Link

import

Inserts the contents of the specified file.

import attributes

Name Description Required Default
file Name of file to read in yes

The following example will load in the file header.html.

<swf:import file="header.html" />

See also: Link

include

Marks a field so that it will be included when displaying a form or table etc. When a field is included all other fields not also explicitly included will be excluded.

include attributes

Name Description Required Default
name Name of the field to be included yes

The include element can be placed within following elements

The following example would produce a form that only shows the contact and date properties from the current object.

<swf:short-form>
  <swf:include name="contact"/>
  <swf:include name="date"/>
</swf:short-form>

See also: Link and Link

initialize

Conditionally sets up a variable when the current RESULT state is set and matches the specified type. If the RESULT state is not set or the type is not the one specified then the variable is not changed/set.

If the RESULT state is not set or the type is not the one specified then and the a variable already exists for the specified name, but with a different scope, then that value is copied across to a variable with the specified scope.

initialize attributes

Name Description Required Default
name Name of variable to initialize yes
scope How long the variable should be kept for no request
type The class name of the type of object that should be used to initialize the variable. This is used to check that RESULT reference is of the correct type. yes

The following will set up the claim variable for the session if the RESULT is a claim object. If the RESULT is not a claim object then the variable will not be set.

<swf:initialize name="claim" scope="session" type="org.scimpi.example.Claim" />

See also: Link

label

Retrieves the name and description of the field within a specified object, and creates an HTML span element containing the name and a title (rendered as a tool tip) from the description.

label attributes

Name Description Required Default
object Identifier for a specific object. no RESULT
field Name of the field to be display the label for. yes

See also: Link

link

Marks a field so that it is hyper-linked when displaying a form or table.

link attributes

Name Description Required Default
name Name of the field to be hyper-linked yes
view The page to forward to no the current page
reference-name Name of the variable to set up with this field's reference no RESULT

The link element can be placed within following elements

  • table
  • short-form
  • edit

See also: Link and Link

list

Creates an list of an object's collection with the collection's object's title displayed in a list.

list attributes

Name Description Required Default
object Identifier for a specific collection, an object that contains a collection, or a service identifier prefixed by "service:". no RESULT
field Name of the field within an object that will provide a collection. yes
type Bullet type - disc, circle or square. If omitted the list will be a number list (HTML OL tag) otherwise a the bullet type is used (HTML UL tag). no disc
link View to forward to if the line is selected. The row is only given a hyper-link if this attribute was specified. no
element-name The name of the variable to assign the row's object ID to when the row is selected. no RESULT
scope How long the linked variable should be kept for. no request

See also: Link, Link and Link

logon

Creates an logon form prompting for username and password. Form passes control to the logon action, which will attempt to authenticate the user through Naked Objects.

logon attributes

Name Description Required Default
legend Title for form no
title Title used for the submit button. no Log in
view View to be forwarded to once the user has logged on. no
errors View to be forwarded to if the log in fails. By default returns to the same view. no

See also: Link

long-form

As for short-form, except that collections are displayed (as in-line tables)

messages

Displays collected messages

See also: Link and Link

methods

Lists all of the methods for a specified object, where each one is displayed as hyper-link, if it is a zero parameter method, or an action button if it has one or more parameters.

methods attributes

Name Description Required Default
object Identifier for a specific object, or a service identifier prefixed by "service:". no RESULT

The methods element can contain one or more of the following elements

new-action-link

Creates a hyper-link to a specified action page with the specified object and method embedded in the URL.

object-link attributes

Name Description Required Default
object Identity of the object to be passed on to the view. no RESULT
method The method to be executed by the forwarded view. yes
view View to be forwarded to. no _generic.html
param-name Name of parameter to pass the object identifier across as. no RESULT

The object-link element can contain one or more of the following elements

  • text
  • HTML elements

The following example creates a hyper-link to the page exit.shtml, passing across the identifier for the claimant object as it does so.

<swf:object-link object="${claimant}" view="edit.shtml">View claimant</swf:object-link>

See also: Link

object-link

Creates a hyper-link to a specified object viewing page with the specified object embedded in the URL.

object-link attributes

Name Description Required Default
object Identity of the object to be passed on to the view. no RESULT
view View to be forwarded to. no _generic.html
param-name Name of parameter to pass the object identifier across as. no RESULT

The object-link element can contain one or more of the following elements

  • text
  • HTML elements

The following example creates a hyper-link to the page exit.shtml, passing across the identifier for the claimant object as it does so.

<swf:object-link object="${claimant}" view="edit.shtml">View claimant</swf:object-link>

See also: Link and Link

page-title

Sets the variable title from the given body. This variable is typically used by page templates to set up the title element in the head. During the remainder of the request the variable can be accessed via ${title}.

The page-title element can contain one or more of the following elements

  • Text
  • Scimpi tags

The example below causes the title to be set with the text "Claim " and the date of the claim referenced by the claim variable.

<swf:page-title>Claim <swf:field object="${claim}" field="dateCreated" /></swf:page-title>

While this tag process the contained elements it also includes any text and HTML tags. This means that white space and line will appear in your title. Always place the variable start and end tags on the same line and only add spaces and new lines within the title where they are actually needed.

See also: Link

parameter

The parameter element specifies a parameter value or reference to be used when invoking an action method.

parameter attributes

Name Description Required Default
number The parameter number (1 through number-of-parameters). no
value The value for the parameter yes

The parameter element can be placed within following elements

The following example sets up the first parameter to the reference held by the claimant variable when the recentClaims method is invoked.

<swf:run-action object="service:Claims" method="recentClaims" />
    <swf:parameter value="${claimant}" />
</swf:run-action>

run-action

Runs the specified action on an object or service.

Where no parameter elements are specified the default values for that parameter will be used.

run-action attributes

Name Description Required Default
object Identifier for a specific object, or a service identifier prefixed by "service:". no RESULT
method Method on the object or service to invoke when this tag is processed. yes
result-name Name of variable to store the resultant object. no RESULT
scope How long the variable should be kept for no request

The run-action element can contain one or more of the following elements

The following example invokes the myRecentClaims method on the claims service and places the result into the RESULT variable.

<swf:run-action object="service:Claims" method="myRecentClaims" />

See also: Link, Link and Link

scope

Changes the scope on a variable, for example can upgrade a request based variable to session scope.

variable attributes

Name Description Required Default
name Name of file to read in yes
scope How long the variable should be kept for no request

The following example assigns the dateCreated property to the date variable, which will be accessible for the remainder of the request. Within the page the variable can be accessed via ${date}.

See also: Link and Link

services

Lists all of the methods for all of the service objects, where each one is displayed as hyper-link, if it is a zero parameter method, or an action button if it has one or more parameters.

The services element can contain one or more of the following elements

selector

Creates a selection widget within an action form or object edit widget. This allows the user to select a reference object for a specified field. In addition to simply providing an option list the selector can also prompt the user for properties used to build the selection list.

selector attributes

Name Description Required Default
field Name of the field or parameter number (param1, param2 etc) to add the selection list for. no
collection Identifier of collection to build the list of options from. If method is specified then collection will be ignored. no RESULT
object Identifier of object to run the search method on. no RESULT
method Search method to run on the specified object. no
id This attribute is passed to the HTML form element. no
class This attribute is passed to the HTML form element. no selector
type Type of selection widget to create: radio; list; or dropdown no dropdown
size Size of list before it must scroll no 5
error View to be forwarded to when the search fails. no _generic.html
title Title for the submission button. no "Search"
legend Title for the generated search form. no the action's name

The radio-list element can be placed within following elements

The following example will make the normal approver field a drop down list that is populated with the elements of the collection returned from the allClaimants method.

<swf:edit object="${claimant}">
    <swf:selector field="normalApprover" object="service:claimants" method="allClaimants"/>
</swf:edit>

See also: Link

short-form

Creates a view of an object with its fields laid out in two columns showing the label and value. Fields that are collections are not displayed in this version.

short-form attributes

Name Description Required Default
object Identifier for a specific object. no RESULT
title Title to be passed through to the HTML table. no
odd-row HTML class to give each odd row of the form; used by CSS to decorated the odd rows. no odd-row
even-row HTML class to give each even row of the form; used by CSS to decorated the even rows. no even-row
link View to forward to when the hyper-linked row is selected. If no link attribute is specified then the rows are not hyper-linked. no

The short-form element can contain one or more of the following elements

See also: Link

specification

Displays details about the object including the class name and names and types of its fields.

selector attributes

Name Description Required Default
always Set to yes if the specification details are to be always shown no no

See also: Link and Link

table

Creates a table view of a collection with the collection's fields used to determine the columns.

table attributes

Name Description Required Default
collection Identifier for a specific collection. If the field attribute is set then the collection will be ignored. no RESULT
object Identifier for a specific object. no RESULT
field Name of the field to get the collection from within the specified object. no
link View to forward to if the line is selected. The row is only given a hyper-link if the this attribute is specified. no
element-name The name of the variable to assign the row's object ID to when the row is selected. no RESULT
scope How long the linked variable should be kept for. no request
heading Determines if column headers should be displayed. no yes

The table element can contain one or more of the following elements

See also: Link, Link and Link

template

The template element causes the specified file to be read in before the rest of the current file is processed. The rest of the current file is then inserted at the point where the content element (see Link) appears within the imported file.

import attributes

Name Description Required Default
file Name of file to read in yes

See also: Link

title

Retrieves the title of the specified object.

title attributes

Name Description Required Default
object Identifier for a specific object, or a service identifier prefixed by "service:". no RESULT
icon If icon is set to "true", "yes" or "on" an icon will also be displayed as well as the text. If set to "false", "no" or "off" no Icon will be shown. no yes

The following example generates the title for the claimant object, without an image.

<swf:title object="${claimant}" icon="no"/>

unless

Processes the contained block when the specified condition is not met.

One of set, field-editable, field-set, empty, or field-empty should be specified, but no more than one.

unless attributes

Name Description Required Default
set If this attribute is specified but evaluates an empty string then the block will be processed; if non-empty the block is skipped. no
empty If the collection referenced by this attribute contains any elements then the body of this block will not be processed no
object Identifier for a specific object when specifying one of the field- attributes. no _result
field-editable Name of the field within the specified object that should not be editable. no
field-set Name of boolean field within the object to check; the block is processed if the boolean value is false. no
field-empty If the field of the specified object is empty - has no reference or the collection has no elements - this block will not be processed. no

The unless element can contain one or more of the following elements

  • Text
  • HTML tags
  • Scimpi tags

The following example uses the unless element to show a message when no claim exits.

<swf:unless set="${claim}">
    <p>No claim selected</p>
</swf:unless>

See also: Link

user

Manages the login process (into the underlying Naked Objects system rather than within the domain model) by providing either a log in or log out link and showing the current user.

user attributes

Name Description Required Default
login-view View to be forwarded to when the user clicks the logon link. no login.shtml
logout-view View to be forwarded to when the user logs out via the log out link. no logout.shtml

The following example will provide a hyper-links to the default login.shtml page when no user is logged in, and to the home page, index.shtml, for logging out.

<swf:user logout-view="index.shtml" />

See also: Link

variable

The variable element assigns the content of the element to a variable held on the server.

variable attributes

Name Description Required Default
name Name of file to read in yes
scope How long the variable should be kept for no request

The variable element can contain one or more of the following elements

  • Text
  • HTML tags
  • Scimpi tags

The following example assigns the dateCreated property to the date variable, which will be accessible for the remainder of the request. Within the page the variable can be accessed via ${date}.

<swf:variable name="date">
  <swf:field object="${claim}" field="dateCreated" />
</swf:variable>

While this tag processes the contained elements it also includes any text or HTML tags. The text may includes white space and line feeds so care is needed if the variable is to be used in textual context as these characters will be displayed also. To avoid this problem place the variable start and end tags on the same line and only add spaces and new lines where they will be needed when the variable is used.

This is not, however, an issue when the variable is used to reference an object as Scimpi will remove any leading and trailing spaces from the variable first.

See also: Link, Link and Link

warnings

Displays collected warnings

See also: Link and Link

when

Processes the contained block when the specified condition is meet.

One of set, field-editable, field-set, empty, or field-empty should be specified, but no more than one.

when attributes

Name Description Required Default
set If this attribute is specified but evaluates to a non-empty string then the block will be processed; if empty the block is skipped. no
empty If the collection referenced by this attribute contains any elements then the body of this block will be processed. no
object Identifier for a specific object when specifying one of the field- attributes. no _result
field-editable Name of the field within the specified object that should be editable. no
field-set Name of boolean field within the object to check; the block is processed if the boolean value is true. no
field-empty If the field of the specified object is empty - has no reference or the collection has no elements - this block will be processed. no

The when element can contain one or more of the following elements

  • Text
  • HTML tags
  • Scimpi tags

The following example uses the when element to show a title and the claim only when the claim exits.

<swf:when set="${claim}">
    <h2>Claim</h2>
    <swf:short-form object="${claim}"/>
</swf:when>

See also: Link