public class Player { private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}}
...
DynaActionForm playerForm = (DynaActionForm) form;
ArrayList playerList = new ArrayList();
Player p1 = new Player();
p1.setName("Brian");Player p2 = new Player();
p2.setName("Henry");playerList.add(p1); playerList.add(p2);
playerForm.set("player",playerList);
...
<logic:iterate id="p" name="playerForm" property="player">
<html:text name="p" property="name" indexed="true" />The form needs to be scoped to session.
<action path="/process" name="playerForm" scope="session" ..
On 30 Dec 2003, at 11:00, Mark Lowe wrote:
<html:text property="player" indexed="true" />
On 30 Dec 2003, at 07:49, Patrick Cheng wrote:
Hi all, I would like to continue on this question, on the jsp side. I tried: <tr> <td>0</td> <td><html:text property="player[0]"/></td> </tr> <tr> <td>1</td> <td><html:text property="player[1]"/></td> </tr> ... So on... But then, this doesn't work. <%for (int i=0;i<4;i++){%> <tr> <td><%=i%></td> <td><html:text property="player[<%=i%>]"/></td> </tr> <%}%> Is that NOT supposed to work? Last question. There is the logic:iterate , I suppose it's the most normal way of doing it, but I can't get it to work, can someone point out the error?
<logic:iterate id="player" name="ViewContactForm" property="playerList"
indexId="ind">
<tr>
<td><%=ind%></td>
<td><html:text property="player" indexed="true"/></td>
</tr>
</logic:iterate>
ViewContactForm is suppose to be the formbean for this jsp, containing
the code suggested below in the previous message. What seems to be the
problem?
Thanks everyone. Rgds, Patrick
-----Original Message----- From: Mohan Radhakrishnan [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 30, 2003 2:16 PM To: 'Struts Users Mailing List'; 'Eric Chow' Subject: RE: array property in ActionForm ???
Hi Seems that you have a List of player objects. If so then indexed bean properties might help. Your form will contain something like the following.
public void setPlayerList(ArrayList playerList){ this.playerList = playerList; }
public ArrayList getPlayerList(){ return playerList ; }
public void setPlayer(int index, Player player){ playerList .add(index, player); }
public Player getPlayer (int index){ return (Player)playerList .get(index); }
Read the doc. for the JSP portion of the solution.
One more solution is the nested tag. I've used nested beans for multiple
levels of nesting. It is so cool.
Mohan -----Original Message----- From: Eric Chow [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 30, 2003 8:25 AM To: Struts Users Mailing List Subject: array property in ActionForm ???
Hello,
<html:form action="/myaction.do"> <html:text property="player"/> <html:text property="player"/> <html:text property="player"/> <html:text property="player"/> <html:text property="player"/>
<html:submit/> </html:form>
In the above JSP, there are five TEXT form field with the same name "player", how can I design my ActionForm code for this case?
I tried,
public void setPlayer(int[] player) { this.player = player; }
public int[] getPlayer() { return player; }
But it seems not working !!!
Best regards, Eric
========================== If you know what you are doing, it is not called RESEARCH! ==========================
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

