Hi All The business requirement on the project which I am currently working on is such that until runtime I don't know that exact # of TextField in JSP page. The Struts requirement is such that you need to declare a attribute in formbean corresponding to each form field in JSP. How can we take care of this requirement of variable number of a form field say TextField in JSP page. I am thinking of a solution in terms of declaring all the TextField in JSP with the same name say 'textfield' and corresponding attribute in the form bean as String textfield ? Is it a limitation in Struts that we can't have variable number of form fields in a JSP or it is already taken care of latest version of Struts. I have gone thorugh the Struts user guide but nowhere I find sufficent documentation which address this particular situation. Thanks in advance Ravindra
You can use a Map based ActionForm that has two methods: public void setValue( String key , Object value ) public Object getValue( String key ) You html:text tag would look like this: <html:text property="value(key)"/> I hope that helps.
Joined: Nov 04, 2000
Hi Mathew What do you mean by Map based ActionForm ? Do I need to declare a attribute in the formbean of data-type Map. If Yes, What does this attribute signify ? How does it maps to the text field on JSP ? Thanks Ravindra
Joined: Mar 09, 2001
Do I need to declare a attribute in the formbean of data-type Map.
Yes. And you use the access methods I mentioned in my previous post.
If Yes, What does this attribute signify ?
It is a Map of the fields you include in it. Instead of your tags writing to a specific property they write to a generic Map as key/value pairs.