Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
titleUsing an expression to set the label
<s:textfield labelkey="%{getText("postalCode.label")}" name="postalCode"/>

The expression language (OGNL) lets us call methods and evaluate properties. The method getText is provided by ActionSupport, which is the base class for most Actions. Since the Action is on the stack, we can call any of its methods from an expression, including getText.

...

Code Block
xml
xml
titleEvaluating booleans
<s:select labelkey="%{getText("state.label")}" name="state" multiple="true"/>

...

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

...

Code Block
xml
xml
titleProbably wrong!
<s:textfield labelkey="%{getText("state.label")}" name="state" value="CA"/>

...

Code Block
xml
xml
titlePassing a literal value the right way
<s:textfield labelkey="%{getText("state.label")}" name="state" value="%{'CA'}" />

...