struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jthomp...@honda.co.nz
Subject Re: newbie question on indexed properties
Date Sat, 10 Jul 2004 01:36:02 GMT





Thanks so much Bill, that worked beautifully.

Regards,
John



|---------+---------------------------->
|         |           Bill Siggelkow   |
|         |           <billsigg@bellsou|
|         |           th.net>          |
|         |           Sent by: news    |
|         |           <news@sea.gmane.o|
|         |           rg>              |
|         |                            |
|         |                            |
|         |           10/07/2004 01:12 |
|         |           AM               |
|         |           Please respond to|
|         |           "Struts Users    |
|         |           Mailing List"    |
|         |                            |
|---------+---------------------------->
  >--------------------------------------------------------------------------------------------------------------|
  |                                                                                      
                       |
  |       To:       user@struts.apache.org                                               
                       |
  |       cc:                                                                            
                       |
  |       Subject:  Re: newbie question on indexed properties                            
                       |
  >--------------------------------------------------------------------------------------------------------------|




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