struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Cheng" <patrick.ch...@hq.oneport.com>
Subject RE: array property in ActionForm ???
Date Tue, 30 Dec 2003 07:49:37 GMT
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:mradhakrishnan@cellexchange.com] 
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:echow@macaucabletv.com]
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message