This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Tag Syntax

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

The tags are designed to display dynamic data. To create a input field that displays the property "postalCode", we'd pass the String "postalCode" to the textfield tag.

Code Block
xml
xml
titleCreating a dynamic input fieldxml
<s:textfield name="postalCode"/>

...

Sometimes, we want to pass the dynamic data to a tag. For example, we might want to display a label with the input field, and we might want to obtain the label from the application's messages resources. Accordingly, the framework will parse expressions found in the tag attributes, so that we can merge dynamic data into the tag attributes at runtime. The expression escape sequence is "%{ ... }". Any text embedded in the escape sequence is evalulated as an expression.

Code Block
xml
xml
titleUsing an expression to set the labelxml
<s:textfield key="postalCode.label" name="postalCode"/>

...

The HTTP protocol is text-based, but some tags have non-String attribute types, like bool or int. To make using non-String attributes intuitative, the framework evaulates all non-String attributes as an expression. In this case, you do not need to use the escape notation. (But, if you do anyway , the framework will just strip it off.)

Code Block
xml
xml
titleEvaluating booleansxml
<s:select key="state.label" name="state" multiple="true"/>

...

Since it's easy to forget which attributes are String and which are non-String, you can still use the escape notation.

Code Block
xml
xml
titleEvaluating booleans (verbose)xml
<s:select key="state.label" name="state" multiple="%{true}"/>
Code Block
xml
xml
titleEvaluating booleans (with property)xml
<s:select key="state.label" name="state" multiple="allowMultiple"/>
Code Block
xml
xml
titleEvaluating booleans (verbose with property)xml
<s:select key="state.label" name="state" multiple="%{allowMultiple}"/>

...

(warning) Since value is not a String, whatever is passed to value is evaluated as an expression - NOT a String literal.

Code Block
xml
xml
titleProbably wrong!xml
<s:textfield key="state.label" name="state" value="ca"/>

If a textfield is passed the value attribute "ca", the framework will look for a property named getCa. Generally, this is not what we mean. What we mean to do is pass a literal String. In the expression language, literals are placed within quotes

Code Block
xml
xml
titlePassing a literal value the right wayxml
<s:textfield key="state.label" name="state" value="%{'ca'}" />

...