Macro Usage in MUM and your application

In MUM, most of the templates call Freemarker macros to display their content. We use macros to consistently generate user interface widgets in HTML. Macros are declared in our "widget" templates, the files /web/templates/widget_*.ftl, divided them in two areas:

  • Widgets that display information to the user (even when they are interactive) are defined in the @show area.
  • Widgets whose main purpose is to allow the user to input information are defined in the @edit area.

Nested content

Many of our macros use h3. Nested content. I strongly recommend that you make yourself confortable with the documentation of Freemarker macros.

Internationalization bundles and keys

MUM searches for keys following the ususal Webwork search order.

Information display macros

Macros to show data are declared inside the widget_show.ftl template.

TOP

@show.page

Shows the html header and body. This includes all necessary CSS and Javascript files, the document type, and so on. Any content you nest in this tag will be added to the body.

The macro also shows flash messages that might have been added by the actions.

Parameters

page title="" lookAndFeel="mum" pageTitle=title onLoad="" debug=false

title (optional, default empty)
the page's main header text.
debug (optional boolean, default false)
if true, will show field errors on the top of the page. It's useful during development.
askForFeedback (optional boolean, default true)
if true, will show the "send us comments" links on the page footer.
lookAndFeel (optional, default mum)
define the look and feel of the page
onLoad (optional, default empty)
a javascript to execute when the body finishes loading.

TOP

@show.tree

This higly specialized macro displays a tree starting from one Marbles object. It also generates javascript controls for drag-and-drop operations associated with an update action. When a node A is dropped on node B, the tree calls an action to update the system, passing A's id as the source id and B's id as the target id.

The root element is always a PObject, as are the first-level elements (which are displayed as the root's children, of course). For each element, the tree searches for its children property effectively displaying a tree of objects.

Parameters

name (required)
name of the tree
updateAction (required)
url of the action that will be called to update the tree.
srcParam (required)
name of the action paramater to pass the source node's id when a drop occurs.
destParam (required)
name of the action parameter to send the target node's id when a drop occurs.
root (optional, default model)
the persistent object to generate the tree from
elements (optional, default root[name])
you can override the first-level elements of the tree with this parameter
highlight (optional, default empty)
an object that must be highlighted when encountered in the tree (usually used for "the current value" kind of trees)
rootIcon (optional, default empty)
an icon to give for the root node.
rootId (optional, default root.id)
the id of persistent object
rootName (optional, default root.name)
the name of persistent object
editable (true/false)
if true, allows to drag and drop the nodes

Nested content

Each element from the tree is passed to the h3. Nested content, which is usually a @show.node macro.

Example

Here's the group tree call from MUM beta4:

<@show.tree updateAction="${base}/group/set-parent.action"
  name="rootGroups"
  root=zone
  srcParam="groupId"
  destParam="parentId"
  rootIcon="${base}/pics/tree/branch_active.gif"
  ; node >
  
</@show.tree>

The call above will use the zone as root element, fetching the first level from the zone's rootGroups property. When a group g1 is dropped on a group g2, an Ajax post will call /{base}/group/set-parent.action?groupId={g1.id}&parentId={g2.id}. This macro will then pass each of the elements it fetched to the omitted inner tag, which contains @show.node tags.

TOP

@show.node

Displays a draggable tree node for use with @show.tree.

Parameters

id (required)
object's id
label (required)
the text to show as node content
editable (required true/false)
if true, allows to drag and drop the nodes
draggable (optional, default true)
if true, the node can be dragged
droppable (optional, default true)
if true, other nodes can be dropped onto this node
onClick (optional, default empty)
some javascript to execute when the node is clicked
icon (optional, defautl empty)
url of an image to use as node icon
tooltip (optional, default empty)
text to use as node tooltip ( title attribute).

Nested content

Whatever you nest inside the node will be considered additional content to be displayed when the user hovers the mouse over the node. Usually, we put links inside to make menus.

Example

The corresponding node call for the tree example above is:

<@show.node
    id=node.id
    label=node.name
    icon="${base}/pics/tree/leaf.gif"
    tooltip="drag node to move it">
  <@show.link obj=node idParam="groupId" label="Manage group" />
</@show.node>

TOP

@show.tabbedPane

Displays a tabbed pane with user actions as links. See also @show.tab below.

Parameters

name (required string)
each tabbed pane on a page must have a unique name
active (optional, default empty)
if provided, will automatically open the tab with the given name.

TOP

@show.tab

Adds a tab to a tabbed pane. By default, tabs use an Ajax call to fetch content from the server and display it inside the tabbed pane. If the content is fetched with Ajax, any forms it contains will be modified to submit their content using Ajax too.

Parameters

name (required)
name of the tab, must be unique within the pane
url (required)
the url the tab-content is loaded using ajax
title (optional, default empty)
a title for the tab link
newPage (optional boolean, default false)
if true, the tab link will open in a new page
linkClass (optional, default empty)
an extra css class for the tab link
separator (optional, defaults to "|")
an extra span with the given text will be shown
processForm (optional boolean, default true)
if true, process the forms in the HTML result to use an ajax hook from the tabbed pane.

Example

<@show.tabbedPane name="main">
  <@show.tab name="first" url="first.action?id=${someId?c}" />
  <@show.tab name="second" url="second.action" processForm=false />
  <@show.tab name="third" url="third.action" newPage=true separator="" />
</@show.tabbedPane>

The macro call above will create a tabbed pane called groupCrud with three tabs. The first two tabs will fetch their content using Ajax, but the second tab will not process its form. This means that the form delivered by second.action will submit to a new page (unless the form itself uses javascript to submit its contents).

The third tab is effectively a normal html link.

TOP

@show.text

Works exactly as @show.string

TOP

@show.time

This Macro will display an instance of org.joda.time.LocalTime or org.joda.time.TimeOfDay as a formatted String according to the locale submitted by the browser. If the requested locale is not found it defaults to U.S. format.

Parameters

name (required)
name of the time attribute
obj (optional)
the PObject (default: ${model})
label (optional)
the label for the property. By default it will be fetched from the bundle key label.{obj.type.name}.{name}, then label.property.{name}. If the argument is missing and none of the keys is found, it uses the value of the name parameter
cssClass (optional, defaults to "label")
a CSS class to give to the paragraph.

TOP

@show_date

This Macro will display an instance of org.joda.time.DateMidnight as a formatted String according to the locale submitted by the browser. If the requested locale is not found it defaults to U.S. format.

Parameters

name
name of the time attribute
obj(optional)
the PObject (default: ${model})
label (optional)
the label for the property. By default it will be fetched from the bundle key label.{obj.type.name}.{name}, then label.property.{name}. If the argument is missing and none of the keys is found, it uses the value of the name parameter
cssClass (optional, defaults to "label")
a CSS class to give to the paragraph.

TOP

@show.a

Shows an html <a> tag, trimmed at the borders and safe against html hacking (see the freemarker documentation for more details).

Parameters

target (required)
url of the link target
label (required)
link text to show (inside the <a> element)
title (optional, default empty)
the link title (shown by most browsers as a tooltip).
targetFrame (optional, default _top)
define wich window will open the link

TOP

@show.menu

Shows a menu with user options. Use with @show.menuItem.

Parameters

title (optional string, default empty)
menu title as text. The macro searches the bundle key menu.{title} or gives the text as plain text.
showHome (optional boolean, defaults to true)
if true shows a link to the home page (/index.action) at the beginning.
homeLink
url for the home

TOP

@show.menuItem

Shows one link in a menu.

Parameters

target (required)
URL for the link target
label (required)
the link text. The macro searches the bundle key menu.{label}, then {label}, then gives it back as plain text.
title (optional, default empty)
the link title (shown by most browsers as a tooltip).
targetFrame (optional, default _top)
define wich window will open the link

TOP

@show.string

Shows a paragraph displaying one property of an object. It's intended to be used with Marbles objects but if you provide a label, anything will do.

Parameters

name (required)
name of the property
obj (optional, defaults to model)
object from which to fetch the property
label (optional)
the label for the property. By default it will be fetched from the bundle key label.{obj.type.name}.{name}, then label.property.{name}. If the argument is missing and none of the keys is found, it uses the value of the name parameter
defaultValue (optional, default empty)
default value used when the property is empty.
cssClass (optional, defaults to "label")
a CSS class to give to the paragraph.

TOP

@show.elementList

Shows an element list inside a <ul> tag. It's only used internally, but you might want to write your own macros with it.

Parameters

name (required)
the list's name
elements (required)
a sequence (i.e. a list, set, array, etc) of objects
idPrefix (required)
a prefix to the ids of the HTML elements
cssClass (optional, default empty)
a CSS class to the <ul> element.

Nested content

The macro will print the Nested content inside each <li> element it produces, passing the element as parameter. See the @show.collection macro below for a good example (@show.collection uses @show.elementList).

TOP

@show.collection

Shows a list of objects. It's used for lists and search results, taking care of proper HTML semantic.

Parameters

elements
The collection of objects that will be displayed
title (optional string, default empty)
list title, displayed inside an <h2> header when provided. The macro searches the bundle key message.results.{title} and passes the collection size as an argument.

Nested content

The Nested content will be called for each of the collection elements, appearing inside <li> elements. Example:

<@show.collection elements=["one", "two", "three"] title="numbers" ; el >
   little piggy number ${el?html}
</@show.collection>

Let's say I have an i18n message with key message.results.numbers and value "little piggy number {0}". The HTML output for the call above will be (element ids ellipsed):

<div class="results">
  <h2>Showing 3 piggies</h2>
  <ul id="..." >
     <li id="...">little piggy number one</li>
     <li id="...">little piggy number two</li>
     <li id="...">little piggy number three</li>
  </ul>
</div>

TOP

@show.link

Displays a link to perform an action on a persistent (i.e. Marbles) object.

Parameters

obj (optional, default model)
the persistent object to manipulate
actionName (optional, default "view")
the name of the action to be called.
namespace (optional)
the namespace to call the action, used to build the URL. By default, we use the object's type lowercased, so that an object of type "Zone" has a namespace "/{base}/zone", where {base} is the web application root.
idParam (optional)
the name of the parameter to send as the object id. Defaults, like the namespace, to the lowercase form of the object's type, but followed by "Id". So an object of type "Group" has the idParam set to "groupId" by default.
label (optional, default empty)
used to to find the bundle key. See below for a complete explanation.
linkMessageKey (optional, default "link.message")
used to build the title property of the <a> tag.
targetFrame (optional, default _top)
define wich window will open the link
cssClass (optional, default empty)
class name for the link
attribute (optional, default name)
the attribute used to get the data to show.

Label and title

The link's labels and titles are fetched from the resource bundle, usually using the object type. The title is fetched trying the keys action.{obj.type.name}.{actionName}, then action.{actionName}. This title is passed as default value and also as a parameter to {linkMessageKey}. For example, let's say the key action.Group.view is defined as "manage group", and the key link.message is defined as the message format "click to {0}" (this is the default, actually). The final title for the link will be "click to manage group".

If a label parameter is given, we search action.{obj.type.name}.{label}, then action.{label}, then {label}. If it's not provided, we load the message format in message.{obj.type.name}.{actionName}, then message.{actionName}, passing the object's name as parameter.

Example

Let's say you want to link to an object of type "User" with id 34 and name "dukejeffrie"

<@show.link obj=user />

This will generate a link similar to:

<a href="/user/view.action?userId=34" title="click to view">dukejeffrie</a>

TOP

@show.info

Shows an information box with one HTML paragraph. Used for notifications to the user such as "your request is being processed."

Parameters

title (optional, default empty)
title text, shown in an <h2> tag if provided. The macro searches the bundle key label.info. {title} and passes the value through if not found.

Example

<@show.info>All your bases are belong to us</@show.info>

will be translated as:

<div class="information">
  <p>All your bases are belong to us</p>
</div>

TOP

@show.help

Shows a help box with an optional title.

Parameters

title (optional, default "Did you know...")
title text, shown in an <h2> tag if provided.

TOP

@show.screenshot

Shows a screenshot image inside a div (so it's formatted properly)

Parameters

file
a filename to be looked under the path /pics/screenshots/.
title
the image title
alt
alternate text, defaults to the image title.

TOP

@show.flashMessages

Shows flash messages created by previous actions to the user. Flash messages are useful when an action executes and then redirects to another url, but needs to show a notification. It creates a <div> with class "flash_messages" and shows each message inside a paragraph. This macro has no parameters

TOP

@show.errors

Shows all action and field errors inside a div with class "errors". Useful for displaying what's wrong when an action fails.

Parameters

title (optional, defaults empty)
if provided, the macro adds a tag <h2> with the given text inside the div.
showFieldErrors(optional, defaults true)
if true will show field errors.
showActionErrors=true (optional, defaults true)
if true will show the action errors.

TOP

Information input macros

Macros to show data are declared inside the widget_edit.ftl template.

TOP

@edit.emptyModel

This function gets a name and returns a hash that can be used to replace an empty Marbles object inside a template. We use it mostly for creation forms.

Parameters

typeName (required)
the name of a persistent type. Usually, it can be anything, but many macros use the type information to look up i18n keys.

Result

A hash with one key called type. The value of type is another hash with the mapping name => typeName.

TOP

@edit.form

Displays a form to edit a Marbles object. It's a very smart macro that is coupled with our action model, so it needs a more detailed description.

Parameters

model (required)
a Marbles object. The macro will pass this reference to other macros that display the property editors.
formId (optional, default empty)
id of the HTML
object. If empty, it will be automatically generated using the model parameter
namespace (optional)
the namespace to call the action, used to build the URL. By default, we use the object's type lowercased, so that an object of type "Zone" has a namespace "/{base}/zone", where {base} is the web application root.
actionName (optional, default "save")
the name of the action to execute
formAction (optional, default empty)
value for the form action. If empty, the macro uses {path}{actionName}.action
title (optional, default empty)
a title for the form. If provided, text is shown inside an <h2> tag.
idParam (optional)
the name of the parameter to send as the object id. Defaults, like the namespace, to the lowercase form of the object's type, but followed by "Id". So an object of type "Group" has the idParam set to "groupId" by default.
method (optional, default "post")
the form submission method, as described in HTML specification.
onSubmit (optional, default empty)
javascript code to be executed upon submit.
cssClass (optional, default empty)
css class name.
enctype (optional, default application/x-www-form-urlencoded)
encryption type.
target (optional, default empty)
target.

Form confirmation

Some actions require a special confirmation token to prevent hacking scripts and <img> calls. The macro tests if a confirmation id is required and generates a hidden field called confirmationId for it.

Model id

If the model argument has an id, it's automatically included as a hidden field with name defined by the idParam parameter.

Nested content

The h3. Nested content is shown inside the tag, within a special <div> of CSS class "object_form" which you can use to style specific elements.

Example

The code below generates a form to change the user's password:

<@edit.form model=user actionName="update">
  <@edit.string name="name" required=true />
  <@edit.controls />
</@edit.form>

When applied to the object with persistent id 171 and name duke, The HTML code generated by this macro call is the following:

<form name="form_User_171" id="form_User_171"
  action="/mum/user/update.action" method="post" onsubmit="">
    <input type="hidden" id="User_171_userId" name="userId" value="171" />
    </div class="object_form" id="object_171">
        <fieldset class="required_field text ">
            <label for="User_171_name">User name:</label>
            <input type="text" id="User_171_name"
            name="name" value="duke" size="25" />
        </fieldset>
        </div class="controls ">
            <input type="submit" value="Save changes" />
        </div> <!— end controls >
    </div> <! end object form —>
</form>

Observe the hidden field with the user id and the action made up of the application content (in my case, "mum") plus object type "User" lowercased, plus the actionName parameter "update".

The rest of this section deals with macros that can be nested inside the @edit.form macro to quickly display data in a consistent way.

TOP

@edit.field

This macro is used to show an object field, potentially adding field errors that an action generated. It can only be used inside a form and most other macros already use it internally.

Parameters

name (required)
the property name for this field.
required (boolean, required)
if true, will style the field with a CSS class "required_field".
obj (optional, default model)
the object from which to fetch the field value.
cssClass (optional, default empty)
additional CSS classes for the field.
label (optional, default empty)
text or i18n key to look up. The macro tries label.{model.type.name}.{label}, then label.{label}, then gives back the parameter untouched. If empty, the macro tries to fetch the property name from the model.

TOP

@edit.select

Used for reference properties, this macro shows a collection of objects inside a select.
h4. Parameters

name (required)
the property name for this field.
elements (required)
a collection of elements to be shown in the field.
property (optional, default empty)
If not empty, used to fetch the option label from each object (see below).
required (optional boolean, default false)
if true, styles the field as a required field.
cssClass (optional, default empty)
additional CSS classes for the field.
label (optional, default name)
label for the select.
id (optional, default empty)
id for the select.

Nested content

For each element in the list, the macro will call the h3. Nested content, passing each element as an argument. Usually the select contains calls to the @edit.option macro.

Examples

The call below creates a select for the zones in MUM's login page.

<@edit.select name="zoneId" elements=zones property="name" />

It creates a <select> tag with name zoneId. For each of the elements, it will show an option with the element's id as value and label defined by the element's name property, like this:

<select id="Login__zoneId" name="zoneId">
  <option value="80">MUM Zone</option>
  <option value="82">Example Zone</option>
</select>

Alternatively, I can use my own nested options. the call above is equivalent to this one:

<@edit.select name="zoneId" elements=zones ; el >
  <@edit.option value=el.id?c label=el.name />
</@edit.select>

TOP

@edit.option

Shows a select option, usually nested in select calls.

Parameters

value (required)
the option value, i.e. what is sent to the server
label (optional, default empty)
the option label, i.e. what is shown to the user. If empty, the macro will use the h3. Nested content as option label.
selected (optional boolean, default false)
if true, the option will be marked as selected in the resulting HTML.

Example

Since there are already examples in the @edit.select above, I'll show you a complicated label and selection. Let's say I have a collection of Feed objects with two parameters, "title" and "url". I want to show the title, with the url in parenthesis:

<@edit.select name="feedId" elements=feeds ; el >
  <@edit.option value=el.id?c >
    ${el.title?html} (${el.url?html})
  </@edit.option
</@edit.select>

TOP

@edit.string

Shows an <input> field of type text to edit a string. It can only be used inside a form.

Parameters

name (required)
the property name for this field.
label (optional, default name)
field label to show.
value (optional, default empty)
value of the field. If empty, the macro will try to get it using the name property from the model (set by the @edit.form macro), then from the value stack. If none is found, it is left empty.
required (optional boolean, default false)
if true, styles the field as a required field.
size (optional integer, default 25)
the size of the input field in characters. CSS styling is preferrable to HTML size changes, so override this option with care.
cssClass (optional, default empty)
additional CSS classes for the field.
js (optional, default empty)
allows you to pass a javascript event listener, like "onclik=alert('click');"

TOP

@edit.text

Exactly the same as @edit.string, but shows a text area. Used for long texts inside a form.

Parameters

name (required)
the property name for this field.
label (optional, default name)
field label to show.
value (optional, default empty)
value of the field. If not provided, the macro will try to get it using the name property from the model (set by the @edit.form macro), then from the value stack. If none is found, it is left empty.
required (optional boolean, default false)
if true, styles the field as a required field.
cols (optional integer, default 25)
default number of columns (in characters) for the text area. CSS styling is preferrable to HTML size changes, so override this option with care.
rows (optional integer, default 10)
default number of rows (in lines) for the text area. CSS styling is preferrable to HTML size changes, so override this option with care.
cssClass (optional, default empty)
additional CSS classes for the field.

@edit.hidden

Shows a hidden field using a Marbles object. It can only be used inside a form. Hidden fields are not displayed inside @edit.form elements.

Parameters

name (required)
the name of the field.
value (required)
the value of the field.

Note that when editing an object, the form macro automatically outputs a hidden field containing the object's id.

TOP

@edit.password

Shows a password field (i.e. an <input> field with type "password") that works much like the @edit.string, except that it never displays a value. It can only be used inside a form.

Parameters

name (required)
the property name for this field.
required (optional boolean, default true)
if true, styles the field as a required field.
size (optional integer, default 25)
the size of the input field in characters. CSS styling is preferrable to HTML size changes, so override this option with care.
cssClass (optional, default empty)
additional CSS classes for the field.

TOP

@edit.date

Provides an input field for a date with a javascript datepicker. The required date format is determined by the locale submitted by th browser and defaults to U.S. format

Parameters

name (required)
The name for the input field
label (optional, defaults to name)
The label for the input field
value (optional, defaults to model[name])
The initial value of the input field. Instance of org.joda.time.DateMidnight
required (optional, defaults to false)
Is the input required?
size (optional, defaults to 25)
the size of the input field
class (optional, default is empty)
a css Class

TOP

@edit.time

Provides an input field for time. The required time format is determined by the locale submitted by th browser and defaults to U.S. format

Parameters

name (required)
The name for the input field
attributeName (optional, default is name)
attribute used to get value from PObject
label (optional, defaults to name)
The label for the input field
value (optional, defaults to model[name])
The initial value of the input field. Insatnce of org.joda.time.LocalTime or org.joda.time.TimeOfDay
required (optional, defaults to false)
Is the input required?
size (optional, defaults to 25)
the size of the input field
class (optional, default is empty)
a css Class

TOP

@edit.controls

Shows control buttons inside a form. At least we show a "submit" button. You can aditionally require "reset" and "cancel" buttons too.

Parameters

submit (optional, default "submit")
key for the submit button.
reset (optional, default empty)
key for the reset button.
button (optional, default empty)
key for the button.
cancel (optional, default empty)
key for the cancel button.
cancelUrl (optional, default empty)
URL to send the browser when the user clicks on "cancel". Only used if the cancel parameter has content.
cancelScript (optional, default empty)
javascript that executes when the user clicks on "cancel". Only used if the cancel parameter has content.
buttonScript (optional, default empty)
javascript that executes when the user clicks on "button". Only used if the button parameter has content.
cssClass (optional, default empty)
additional CSS classes for the controls <div>, in addition to the class "controls".

i18n Keys

The i18n keys are searched like this:

  • the key for the submit button is searched first as control.{model.type.name}.{submit}, then control.{submit}, then passes the contents of the parameter untouched.
  • the key for reset button is searched depending on the submit key: first control.{model.type.name}.{submit}.reset, then control.{submit}.reset, then control.{reset}, then the parameter untouched.
  • the key for the cancel button is searched exactly like reset: first control.{model.type.name}.{submit}.cancel, then control.{submit}.cancel, then control.{cancel}, then the parameter untouched.

Examples

The call below shows a single submit button:

<@edit.controls />

The call below shows all form controls, just skipping

<@edit.controls
  submit="my_submit"
  reset="reset"
  cancel="cancel"
  cancelScript="javascript:history.go(-1)"/>

TOP

@edit.tree

Shows a tree hierarchy for user selection inside a field.

Parameters

name (required)
the name for the tree. Must be unique between all trees for the same object.
elements (optional sequence)
collection of Marbles objects to use as root elements. If not provided, the macro will try to get it using the name property from the model (set by the @edit.form macro). If not found, it's considered empty.
required (optional boolean, default true)
if true, styles the field as a required field.

Nested content

Much like the @show.tree macro, the h3. Nested content is called for each node in the tree. Currently, we provide two input types, checkbox and radio button.

The children of each element are fetched from the element's children property.

Example

Below is the tree call used to select groups for a user in MUM. The user variable is the current user and the currentGroups is a list taken from the action.

<@edit.tree elements=rootGroups name="groups" ; group>
  <#assign checked = user.groups.contains(group) />
  <@edit.treeCheckbox
    name="groupsIds"
    value=group.id?c
    label=group.name
    selected=checked />
</@edit.tree>

For each node, the nested code will be called, displaying a check box with the group's ID as the value and the group's name as the label. If the group belongs to the collection user.groups, the checkbox is selected.

TOP

@edit.treeCheckbox

Shows a checkbox with a label right after it. Mostly used in trees.

Parameters

name (required)
the name for the checkbox field.
value (required)
the value of the field.
label (required)
the label for the field.
enabled (optional boolean, default true)
if true, the checkbox will be enabled.
selected (optional boolean, default false)
if true, the checkbox will be selected (checked) when shown.

@edit.treeRadio

Shows a radio button with a label right after it, exactly like the treeCheckBox.

Parameters

name (required)
the name for the radio button field.
value (required)
the value of the field.
label (required)
the label for the field.
enabled (optional boolean, default true)
if true, the radio button will be enabled.
selected (optional boolean, default false)
if true, the radio button will be selected (checked) when shown.

TOP

@edit.memberSet

Very specific macro that shows a membership selection widget with two lists, one containing the current members, the other containing the available elements. The macro also displays "add" and "remove" buttons that allows the user to move them from one list to the other and a "save" button to save the current members list.

Note that this macro uses javascript to move elements around.

Parameters

name (required)
the property name for this field.
elements (required sequence)
collection of the current members
available (required sequence)
collection of the available elements
optionLabel (optional default name)
collection of the available elements
cssClass (optional default empty)
collection of the available elements
has_submit (optional default true)
if true creates a save button
labelLeft (optional default empty)
define the label for the right select box
labelRight (optional default empty)
define the label for the right select box

TOP

@edit.search

Shows a live search field. Results will be displayed as a list of links below the field. This macro doesn't need a form to work, you can call it anywhere.

Parameters

title (required)
text to show for the input label
url (required)
main url for the Ajax query
name (required)
name for the search field, must be unique in the page
parameters (default is empty)
extra parameter for the search

Data macros

Macros to show data are declared inside the widget_data.ftl template.

TOP

@data.table

Shows a table with the given elements. The action that before this view must extends from BasicPaginationAction and implement all of it methods in order to this macro work properly with pagination.

Parameters

label (required)
text for the table title
elements (required)
Collection of elements
url (required)
url to keep the table state
headerClass
css class name for the header
param
parameters to keep the table state
id
table's id

Example

<@data.table id="users" elements=users label="user.list" url="/list.action"; user>
  <@data.column label="Login" sortBy="login">${user.login}</@data.column>
  <@data.column label="Name" sortBy="name">bruno</@data.column>
  <@data.deleteColumn obj=user url="/delete-users.action" paramId="users"
  noneSelectedMessage="Select an user"/>
</@data.table>

TOP

@data.column

Must be used as child of @data.table to build a dynamic table. The enable the sorting feature the Action must extend from SortablePaginationAction.

Parameters

label (required)
text to show for the title of the column
sortBy
name for the attribute used in the sorter
id
title's id
cssClass
css class name

TOP

@data.deleteColumn

This is a specialization of the @page.column. Provides a column with an image for the delete action. It has a multi-selection feature, that enables the user the select one or more itens at the same time. Because of that, your Delete Action must expect a List<PObjects> insted of a single PObject.

Parameters

noneSelectedMessage (required)
text to inform the user that none itens were selected
url (required)
url for deleting the selected elements
paramId (required)
obj (required)
obj to delete
paramId (required)
param name of the element
onUnCheck
Javascript callback function name for when a element is unchecked
onCheck
Javascript callback function name for when a element is checked
onNoneItens
Javascript callback function name for when user is trying to delete, but none elements are selected
onExecute
Javascript callback function name for when the delete is executed

TOP

@data.pagination

Shows the navigation for the pagination feature.

Parameters

url (required)
url to list elements
labelItens
text for pagination
param
parameters used to list elements

TOP

@data.pagesList

Shows the navigation by listing the pages.

Parameters

lastPageNumber (required)
number of the lastPage
url (required)
url to list elements
param (required)
parameters used to list elements

TOP

Information Tab macros

Macros to show data are declared inside the widget_data.ftl template.

TOP

@tab.container

Displays a tab container. See also @tab.item

Parameters

id (required)
id for the container
cssClass (default is empty)
css class name for the container
activeCssClass (optional, default is 'active')
css class name for the active tab
beforeChangeCallback (optional, default is empty)
Javascript callback function called before activating a tab
afterChangeCallback (optional, default is empty)
Javascript callback function called after activating a tab

Example

<@tab.container id="tab">
  <@tab.item id="option1" label=action.getText("label.groups.title")>
      <h1>Example Tab1</h1>
  </@tab.item>
  <@tab.item id="option2" label=action.getText("label.groups.title")>
    <h1>Example Tab2</h1>
  </@tab.item>
  <@tab.item id="option3" label=action.getText("label.groups.title")>
      <h1>Example Tab3</h1>
  </@tab.item>
</@tab.container>

TOP

@tab.item

Displays a single tab

Parameters

id (required)
id for the tab
label (required)
text for the tab
cssClass (default is empty)
css class name for the tab
show (optional, default is 'active')
if true will start being displayed

Nested Content

In the nested content please put the content of this tab. Check example

Example

<@tab.container id="tab">
  <@tab.item id="option1" label=action.getText("label.groups.title")>
    <h1>Example Tab1</h1>
    <p>Here you can place anything you want...<p>
  </@tab.item>
</@tab.container>

TOP

Please send us comments, questions, criticism:

Please send us comments, questions, criticism!