This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Struts and the fly likes Tag that display a list in Struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Tag that display a list in Struts 2" Watch "Tag that display a list in Struts 2" New topic
Author

Tag that display a list in Struts 2

Vo Hien
Greenhorn

Joined: Mar 27, 2007
Posts: 15
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

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
Vo Hien
Greenhorn

Joined: Mar 27, 2007
Posts: 15
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tag that display a list in Struts 2
 
Similar Threads
Struts2: Retern all the values inside the list in my Action
How to reterive table row value (JSP )from the action class
Data mismatch between two separate lists in a single iterator in struts2
dynamic checkboxes in struts 2
Struts2 Checkbox: How to set value back to Bean