Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>AFAIK you must use:</p> <pre><code> &lt;s:form action="hello-world"&gt; &lt;s:textfield name="helloBeans[1].name" label="name1"/&gt; &lt;s:textfield name="helloBeans[1].age" label="age1"/&gt; &lt;s:textfield name="helloBeans[2].name" label="name2" /&gt; &lt;s:textfield name="helloBeans[2].age" label="age2"/&gt; &lt;s:submit /&gt; &lt;/s:form&gt; </code></pre> <p>I think the biggest issue is not that it must be done this way but that you think that this means it can not be dynamic, consider that the text fields are rendered more-less (actually less because I removed the 'id' and 'value' attributes):</p> <pre><code>&lt;input type="text" name="helloBeans[1].name"/&gt; &lt;input type="text" name="helloBeans[1].age"/&gt; ... </code></pre> <p>There is no reason you simply can not either handle this in your jsp dynamically as done to test the view:</p> <pre><code> &lt;h1&gt;Display HelloBeans&lt;/h1&gt; &lt;table&gt; &lt;s:iterator value="helloBeans"&gt; &lt;tr&gt; &lt;td&gt;&lt;s:property value="name"/&gt;&lt;/td&gt; &lt;td&gt;&lt;s:property value="age"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/s:iterator&gt; &lt;/table&gt; </code></pre> <p>Or if your issue is client side then use JavaScript (or better a JS library such as jQuery) to add new text fields to the DOM... and use string concatenation to build the correct OGNL for the 'name' attributes.</p> <p>Note if your dynamic behavior is server side in the JSP then</p> <pre><code>&lt;s:property value="#helloBeans.index" /&gt; </code></pre> <p>will get you the index of the current iteration when used inside the s:iterator tag.</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. This table or related slice is empty.
    1. This table or related slice is empty.
    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