File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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

Tag that display a list in Struts 2

Vo Hien

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 id="item-left">
<s roperty value="functionName" />
<td id="checkbox">
<s:checkbox name="view" value="%{view}" theme="simple"/>
<td id="checkbox">
<s:checkbox name="add" value="%{add}" theme="simple"/>
<td id="checkbox">
<s:checkbox name="delete" value="%{delete}" theme="simple"/>
<s:checkbox name="update" value="%{update}" theme="simple"/>

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.

Consultant, Sima Solutions
Vo Hien

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:
subject: Tag that display a list in Struts 2
It's not a secret anymore!