Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have an action, with a property as follows - </p> <pre><code>private Map&lt;String,String&gt; assetProps; ... public Map&lt;String, String&gt; getAssetProps() { return assetProps; } public void setAssetProps(Map&lt;String, String&gt; assetProps) { this.assetProps = assetProps; } </code></pre> <p>To set values onto the map, there are basically two steps. First off, OGNL can't instantiate the map, so it is up to you. In my action, I implement the Preparable interface, but instantiate it before running the 'public String input()' method as follows - </p> <pre><code>public class EditAction extends ActionSupport implements Preparable { ... public void prepare() { // just satisfying Preparable interface so we can have prepareInput() } public void prepareInput() throws Exception { assetProps = new HashMap&lt;String,String&gt;(); } </code></pre> <p>Now, the object is non-null, I can use syntax similar to the following in the JSP - </p> <pre><code> &lt;s:iterator value="asset.properties" var="prop"&gt; &lt;sjx:textfield name="%{'assetProps[\\'' +#prop.propName +'\\']'}" value="%{#prop.propValue}" label="%{#prop.propName}" size="25"/&gt; &lt;/s:iterator&gt; </code></pre> <p>The iterator pulls a set of objects off the stack and iterates over it. The important part is the "name=" section, notice the double-escaped single quotes. That way, when the page renders, the name of the input element becomes (for example) - assetProps['Screen Size']. When the page is submitted, inside the "public void execute()" method, assetProps is fully populated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload