Child pages
  • How do we access static parameters from an Action
Skip to end of metadata
Go to start of metadata

Static (or pre-defined) parameters can be set to a Map property or to individual JavaBean properties.

  • Define the parameters to be set by adding the name(s) and value(s) to the action mapping element (in the application's struts.xml.
  • Ensure that staticParams Interceptor is included in the Action's stack.
    • (info) The default stack already includes staticParams.
  • Edit the Action so that it implements the Parameterizable interface.

Map property

  • Ensure the Action defines a setParams(Map) method.
  • The staticParams Interceptor will set the defined values to the Map, using the name as the entry key.

key

value

myStaticParam1

myStaticValue1

myStaticParam2

myStaticValue2

myStaticParam3

myStaticValue3

JavaBean properties

  • Ensure that the Action defines JavaBean properties corresponding to the param elements in the action mapping.
  • The staticParams Interceptor will set the defined values to each JavaBean property that corresponds to a param element.

@see com.opensymphony.xwork.interceptor.StaticParametersInterceptor
@see com.opensymphony.xwork.config.entities.Parameterizable

  • No labels

1 Comment

  1. Please fix || into }} in the last sentence (beginning with "The static-params Interceptor...") so that the Wiki markup correctly displays.