Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tag that display a list in Struts 2

 
Vo Hien
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,

I have problems when using Struts 2

I use an iterator tag to display a list in jsp file.

<s:iterator value="%{functionList}" id="functionList">
<tr class="table-item">
<td >
<s roperty value="id" />
</td>
<td id="item-left">
<s roperty value="functionName" />
</td>
<td id="checkbox">
<s:checkbox name="view" value="%{view}" theme="simple"/>
</td>
<td id="checkbox">
<s:checkbox name="add" value="%{add}" theme="simple"/>
</td>
<td id="checkbox">
<s:checkbox name="delete" value="%{delete}" theme="simple"/>
</td>
<td>
<s:checkbox name="update" value="%{update}" theme="simple"/>
</td>
</tr>
</s:iterator>

functionList is a property (LinkedList) of a JavaBean and I implements two interfaces ModelDriven and Prepareble in the Action class. I can display the functionList successfully in the Jsp file but when I click on the Submit button to update the information, in the Action class I receive an null functionList while I expect an list with value that I have changed in the jsp file.

My question is how to get the the list(with the information has been changed) from jsp file and update it to database. What tag should be use to display a list of data and still remain the the changed data in Action class.

Thank you very much indeed.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For an example of how to do this sort of thing, deploy the struts2-showcase-2.0.6.war file that comes with the download and look at the Person Manager example. In this example, you will see how to create a list of objects that is also updateable. To see the source code, unzip the war file and you will find a src directory inside WEB-INF.
 
Vo Hien
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your reply.

I have tried with the struts2-showcase-2.war file and I solved the problem.

The problem is that I don't have a .properties file.

Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic