You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Peter Wu <pe...@gmail.com> on 2005/02/02 19:55:47 UTC

Indexed Properties

Hi group,

I'm using Struts 1.2.4 w/ Tomcat 5.5.4. I'm designing a page that contains a 
grid of cells, like an Excel sheet.

In the grid, there are a couple of cells, which could textboxes.

In the JSP, I put the following tags.

<table>

<tr>
<td>
<html:select property="project[0]">
             <html:option value="a">0-19</html:option>
             <html:option value="b">20-49</html:option>
             <html:option value="c">50-</html:option>
           </html:select>
</td>
<td><html:text property="hour[0][0]"/></td>
</tr>

<tr>
<td>
<html:select property="project[1]">
             <html:option value="a">0-19</html:option>
             <html:option value="b">20-49</html:option>
             <html:option value="c">50-</html:option>
           </html:select>
</td>
<td><html:text property="hour[1][0]"/></td>
</tr>

</table>

This is just an example. I want to have a project[] array and a hour[][] array 
to contain necessary information so that in the backend, I only need to 
process arrays instead of something like project0, project1, hour00, hour10.


I tried to put something as follows in the ActionForm, but no luck.

 private String[] project = new String[2];
    private double[][] hour = new double[2][2];

     public double getHour(int i, int j) {
        return this.hour[i][j];
    }

    public void setHour(int i, int j, double hour) {
        this.hour[i][j] = hour;
    }

    public String getProject(int i) {
        return this.project[i];
    }

    public void setProject(int i, String project) {
        this.project[i] = project;
    }


I googled some examples but they are for Struts 1.1. Your help would be 
appreciated. Thanks.


Peter


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


RE: Indexed Properties

Posted by Nigel Furber <ni...@boxfordpark.com>.
Using the nested version of tags rather than html and logic worked for me.

See http://www.keyboardmonkey.com/next/index.jsp, they have some examples

and the normal Struts how-tos.

Nigel Furber


-----Original Message-----
From: news [mailto:news@sea.gmane.org]On Behalf Of Peter Wu
Sent: 02 February 2005 20:41
To: user@struts.apache.org
Subject: Re: Indexed Properties


Peter Wu <peter.ying.wu <at> gmail.com> writes:

> <html:select property="project[0]">
>              <html:option value="a">0-19</html:option>
>              <html:option value="b">20-49</html:option>
>              <html:option value="c">50-</html:option>
>            </html:select>

This one works fine now.

> </td>
> <td><html:text property="hour[0][0]"/></td>

hour[i][j] does not work.


How to make a 2-dimensional array work with Struts? Thanks in advance!


Peter


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



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


Re: Indexed Properties

Posted by Peter Wu <pe...@gmail.com>.
Peter Wu <peter.ying.wu <at> gmail.com> writes:

> <html:select property="project[0]">
>              <html:option value="a">0-19</html:option>
>              <html:option value="b">20-49</html:option>
>              <html:option value="c">50-</html:option>
>            </html:select>

This one works fine now.

> </td>
> <td><html:text property="hour[0][0]"/></td>

hour[i][j] does not work.


How to make a 2-dimensional array work with Struts? Thanks in advance!


Peter


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