I figured it out.  I need to have an intermediate "bean" to hold the values.
Thanks for you help.  I do think it would be very helpfull if an options tag
where passed only collection it call the toString method.  At least things
wouldn't blow up.  In a great many cases that would be the simplest thing.

Thank you,
Chris

Princeton Lau wrote:

> Chris,
>
> What sort of errors are you getting?
>
> Below is a reprint of a message I posted a few weeks ago.  I believe it
> addresses a similar question.
>
> Princeton
>
> Re: html:options not understanding collections from form beans?
>
> ----------------------------------------------------------------------------
> ----
>
> From: Princeton Lau
> Subject: Re: html:options not understanding collections from form beans?
> Date: Fri, 17 Aug 2001 10:14:38 -0700
>
> ----------------------------------------------------------------------------
> ----
>
> Hello,
>
> I struggled with the options tag because I did not understand what it meant
> by 'collection'.  I could not pass a collection along with a request because
> I was at my index page.  In other words, nothing had been done yet.
>
> I instantiated the bean that had the collection and then used a <bean:define
> .../> to make the collection visible to the options tag.
>
> This is a sample define statement for a bean named Cost, with an ArrayList
> (an array of costCentre objects) called costCentres.
> <bean:define id="CostList" name="Cost" property="costCentres"/>
>
> I then reference it in my form via:
> .
> .
> .
>       <html:select property="costCentre" size="0">
>         <html:options collection="CostList" property="value"
>                    labelProperty="label"/>
>       </html:select>
> .
> .
> .
>
> I hope this helps.
>
> Princeton
>
> -----Original Message-----
> From: Chris Heinemann [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 13, 2001 1:23 PM
> To: Struts User Group
> Subject: HTML:OPTIONS
>
> I have a collection of java.lang.String objects.  How do I get the
> html:options tag to output them?
>
> My code is :
> <%
> Collection c = reportBuilder.getAvailableStartDates();
> pageContext.setAttribute("availStartDates",c);
> %>
>
> <html:form action="updateReport.do" name='reportBuilder'
> type='ReportBuilderActionForm' scope='session' >
> <html:select property='startWeek' name='reportBuilder' multiple='false'
> value='<%=reportBuilder.getStartWeek()%>' >
>  <%
> try{
>
> //I know this is where things are breaking.... I have tried serval
> variations to no avail
> %>
>  <html:options collection='availStartDates' />
> <%}catch (Exception h){
> h.printStackTrace();  //because things don't work... this might give a
> clue :(
>   }
> %>
> </html:select>
> </html:form>
>
> Thanks,
> Chris Heinemann

Reply via email to