struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Siggelkow <bills...@bellsouth.net>
Subject Re: newbie question on indexed properties
Date Fri, 09 Jul 2004 13:12:56 GMT
You will need to add indexed getters and setters --

public String getAnswer(int index);
public String setAnswer(int index, String value);

   <logic:iterate name="questionForm" property="answers"
                id="answer" indexId="ctr">
     <br/><html:text property=’<%="answer["+ctr+"]"%>’/>
   </logic:iterate>

jthompson@honda.co.nz wrote:
> 
> 
> 
> I have a form bean with a string array defined as a property, with a
> corresponding set/get like this:
> 
> private String[] answers = { "Answer 1","Answer 2","Answer 3","Answer
> 4","Answer 5" };
> public String[] getAnswers() { return (this.answers);  }
> public void setAnswers(String[] value) { this.answers = value; }
> 
> 
> On my jsp I've coded the following iteration to display array 'answers' and
> it works fine:
> 
> <c:forEach var="row" items="${questionForm.answers}">
>      <c:out value='${row}'/></br>
> </c:forEach>
> 
> 
> But rather than just display these rows, I'd like to write them as
> textareas that can be read back into the form-bean.
> I've read quite a few postings regarding this, but nothing I've seen and
> tried seems to work.
> 
> Has anyone actually done this with any success?
> 
> 
> Regards,
> John


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


Mime
View raw message