2d array with struts
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Justin_Hamilton
Posted On:   Tuesday, May 14, 2002 07:21 AM

I have a form that has a major portion of it imported from another file based on the selection in a html:select box. As there are many possible form endings that can be imported, I have opted to save the data entered in the imported form in an array. So, I have the following getter/setters in my formBean:     private String[] hobbies = new String[50];     public String getHobbies(int i)     { return this.hobbies[i];     }     public void setHobbies(int i, String newValue)     { this.hobbies[i] = newValue;     } and refer to it in my jsp file with:    More>>

I have a form that has a major portion of it imported from another file based on the selection in a html:select box.


As there are many possible form endings that can be imported, I have opted to save the data entered in the imported form in an array.


So, I have the following getter/setters in my formBean:



    private String[] hobbies = new String[50];



    public String getHobbies(int i)

    { return this.hobbies[i];

    }



    public void setHobbies(int i, String newValue)

    { this.hobbies[i] = newValue;

    }




and refer to it in my jsp file with:


   



However, this causes the same text to be used for all variations of the form (if I change the selection in the option box, the data in the old form will still be in the new form)



So, I would like to use a 2d array to store the information to avoid this issue.



Does anyone know how to write a bean & jsp code to access a 2d array in struts?



Thanks.

   <<Less
About | Sitemap | Contact