On Wednesday 20 May 2009 11:25:50 pm Bhaarat Sharma wrote: > hi > > I have a form that will have varying number of fields inside it. The > number of fields is generated dynamically and is not always the same. When > I am submitting this form to my action class, is there a way to get all the > fields back in a systematic manner? Does struts2 provide any mechanism to > do this? or am i Stuck with the good old fasioned way of naming my fields > with a prefix name and then keep looking for names in forloop untill they > run out. > > Thanks!
Put the values in a collection of some sort, then just use indexed names. For instance - <s:textfield name="fieldName[0]" ... /> ... <s:textfield name="fieldName[n]" ... /> then in the page where you want to display the values - <s:iterator value="fieldName" var="field"> <s:property value="field" /> </s:iterator> -Wes -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org