Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The main thing to remember here is that when validation fails, struts just renders the jsp page the same as it did when you first entered the page, just with the form fields already populated. Since your jsp page only displays one row, the form only has one row after it gets regenerated after validation.</p> <p>If you want all the rows to show up, you will need to use an s:iterator tag, to iterate over the saved values. Given the fact that you only have one instance of addComponent, and the values of that object are the arrays, you actually need to iterate over one of the attributes of addComponent, but set the name of the form field to the fully qualified object name, including an array index. You use the iterator status object in order to get the index of the array. Try something like the following in place of your dataTable above:</p> <pre><code>&lt;table id="dataTable" border="1"&gt; &lt;s:iterator value="addComponent.partNumber" status="componentStatus"&gt; &lt;tr&gt; &lt;td&gt;&lt;s:checkbox name="test" id="chk" /&gt;&lt;/td&gt; &lt;td&gt;&lt;s:textfield name="addComponent.partNumber[%{#componentStatus.index}]" id="txt" /&gt;&lt;/td&gt; &lt;td&gt;&lt;s:textfield name="addComponent.componentDescription[%{#componentStatus.index}]" id="txt"/&gt;&lt;/td&gt; &lt;td&gt;&lt;s:textfield name="addComponent.quantity[%{#componentStatus.index}]" id="txt"/&gt;&lt;/td&gt; &lt;td&gt;&lt;s:textfield name="addComponent.unitPrice[%{#componentStatus.index}]" id="txt"/&gt;&lt;/td&gt; &lt;td&gt;&lt;s:textfield name="addComponent.totalPrice[%{#componentStatus.index}]" id="txt"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/s:iterator&gt; &lt;/table&gt; </code></pre> <p>If that does not work, you may try just playing around with the syntax a bit. Using an iterator is definitely the best way to go here.</p> <p>Here are some more links for some more information.</p> <ul> <li><a href="http://struts.apache.org/2.0.14/docs/iterator.html" rel="nofollow">http://struts.apache.org/2.0.14/docs/iterator.html</a></li> <li><a href="http://www.roseindia.net/struts/struts2/struts2controltags/iterator-tag.shtml" rel="nofollow">http://www.roseindia.net/struts/struts2/struts2controltags/iterator-tag.shtml</a></li> <li><a href="http://www.mkyong.com/struts2/struts-2-iterator-tag-example/" rel="nofollow">http://www.mkyong.com/struts2/struts-2-iterator-tag-example/</a></li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. 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