Hi,
I have an object in my Action class which contains an arraylist of objects internally, I am trying to create a CRUD screen for this object. My Action Class and bean are given below,
/**
* @author rohit
*
*/
public class IRFeedMgmtAction extends ActionSupport implements ModelDriven<IRFeeds>,SessionAware,ServletRequestAware {
private static org.apache.log4j.Logger log = Logger.getLogger(IRFeedMgmtAction.class);
private HttpServletRequest request;
private Map session;
private IRAccountsDAO acctsDAO;
private IRFeeds feed = new IRFeeds();
/* (non-Javadoc)
* @see com.opensymphony.xwork2.ActionSupport#execute()
*/
public String execute()
{
return "success";
}
/**
* @return
*/
public String add()
{
IRUser user = (IRUser) session.get("user");
List<IRAccountUsers> twtUsers = acctsDAO.getTwitterAcctByOrgId(user.getOrgId());
feed.setTwtAccts(prepareTwitterAccounts(twtUsers));
return "addFeed";
}
/**
* @return
*/
public String save()
{
IRFeeds fd = getFeed();
ArrayList<IRFeedAccts> twtAccts = fd.getTwtAccts();
System.err.println(fd.getFeedUrl());
for (Iterator iterator = twtAccts.iterator(); iterator.hasNext();)
{
IRFeedAccts irFeedAccts = (IRFeedAccts) iterator.next();
System.err.println(irFeedAccts.getNumber());
}
return "saved";
}
/**
* @return
*
*/
private ArrayList<IRFeedAccts> prepareTwitterAccounts(List<IRAccountUsers> twtUsers)
{
ArrayList<IRFeedAccts> twtAccts = new ArrayList<IRFeedAccts>();
IRAccountUsers twtUser = null;
IRFeedAccts feedAccnt = null;
for (Iterator iterator = twtUsers.iterator(); iterator.hasNext();)
{
twtUser = (IRAccountUsers) iterator.next();
feedAccnt = new IRFeedAccts();
feedAccnt.setAccountId(twtUser.getSocialId());
feedAccnt.setPic(twtUser.getPic());
feedAccnt.setName(twtUser.getTwtUsrName());
feedAccnt.setNumber(30);
twtAccts.add(feedAccnt);
}
return twtAccts;
}
MY BEAN
public class IRFeeds implements java.io.Serializable {
private Integer feedId;
private Integer campId;
private String feedUrl;
private boolean active;
private Date createdOn;
private Date updatedOn;
private String createdBy;
private ArrayList<IRFeedAccts> twtAccts;
private ArrayList<IRFeedAccts> fbAccts;
private ArrayList<IRFeedAccts> fbPages;
MY JSP FILE
<s:iterator value="#session.fd.twtAccts" status="twtAcct">
<tr>
<td>
<div style="width: 48px; float: left;"><img src="<s:property value="pic" />" /></div>
<div style="text-align: left;"><s:property value="name" /></div>
</td>
<td>
<s:textfield name="number"/>
</td>
<td>
<input type="text" />
</td>
<td>
<s:textfield name="signature"/>
</td>
</tr>
</s:iterator>
Now my problem is when the value of the beans in the arraylist is modified in the JSP, the same doesn't reach the action class save method. The value remains the same.
Regards, Rohit