Ahh..., well that makes it simple.

THX

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 19, 2001 3:09 PM
> To: [EMAIL PROTECTED]
> Subject: RE: html:select/options
>
>
>
>
> Not sure I understand...
>
> I just set the value of roleName in my FORM, and whatever is set there is
> reflected as the selected item - ie just leave off the value=
> altogether (as
> Jason's code).
>
> Dave
>
>
>
>
>
> "DHarty" <[EMAIL PROTECTED]> on
> 07/19/2001 01:33:39 PM
>
> Please respond to [EMAIL PROTECTED]
>
> To:   [EMAIL PROTECTED]
> cc:    (bcc: David Hay/Lex/Lexmark)
> Subject:  RE: html:select/options
>
>
>
> The problem is in the origionally "selected" item when the page
> is rendered.
> for example
>
> >     <html:select name="userForm" property="roleName"
> value="Team Leader">
> >        <html:option value="-1">-- Select a Role -- </html:option>
> >        <html:options collection="Roles" property="name" />
> >     </html:select>
>
> would set the roleName "TeamLeader" as selected by default.
> However, if you
> don't wan't the page designers to have to worry about the
> initially selected
> value, or want to make it dynamic, you would have to use something like:
>
>
> >     <html:select name="userForm" property="roleName"
> value="<%=bean.getTheItemWeWantSelected">
> >        <html:option value="-1">-- Select a Role -- </html:option>
> >        <html:options collection="Roles" property="name" />
> >     </html:select>
>
> whick commingles JSP and struts' tags.  It works, but it aint pretty.
>
> D
>
> PS:  Does anyone know, if I use
>      <%jsp:useBean id="bean"...>
> could i then use
>      <html:select ...  value='<jsp:getProperty id="bean"
> property="theItemWeWantSelected">'>
>
> Thanks
>
>
>
> > -----Original Message-----
> > From: Jason Te Whau [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, July 19, 2001 12:55 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: html:select/options
> >
> >
> > This works for me:
> >
> >     <html:select name="userForm" property="roleName">
> >        <html:option value="-1">-- Select a Role -- </html:option>
> >        <html:options collection="Roles" property="name" />
> >     </html:select>
> >
> > where the userForm.getRoleName() method will return a value that matches
> > with one of the values returned by the getName() method of the objects
> > stored in the Roles collection.
> >
> > HTH
> >
> > -----Original Message-----
> > From: DHarty [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, July 19, 2001 6:31 AM
> > To: [EMAIL PROTECTED]
> > Subject: RE: html:select/options
> >
> >
> > Good question, and what if you want to get the value from a bean?
> >
> > Is value='<@=bean.getsomthing()%>' the only way?
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: Pham Thanh Quan [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, July 18, 2001 9:23 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: html:select/options
> > >
> > >
> > > But how to keep the choice that user chose in the last time
> he submitted
> > >
> > > ----- Original Message -----
> > > From: Joe Clark <[EMAIL PROTECTED]>
> > > Sent: Wednesday, July 18, 2001 11:12 PM
> > > Subject: RE: html:select/options
> > >
> > >
> > > > Use the 'value' attribute to make the selection. For example
> > assume you
> > > > have a dropdown of countries and one entry is 'United
> States' the code
> > > > below would select 'United States'.
> > > >                                                       <html:select
> > > > property="country" value="United States">
> > > > ...
> > > > </html:select>
> > > >
> > > > -----Original Message-----
> > > > From: [EMAIL PROTECTED] at INTERNET
> > > >
> > [mailto:IMCEACCMAIL-struts-user+40jakarta+2Eapache+2Eorg+20at+20INTERNET
> > > > @alltel.com]
> > > > Sent: Wednesday, July 18, 2001 10:38 AM
> > > > To: Clark, Joe; [EMAIL PROTECTED] at INTERNET
> > > > Subject: html:select/options
> > > >
> > > >
> > > >  Is there a way to dictate which "option" in a collection
> is initially
> > > > set
> > > > as
> > > >  "selected" when the page is rendered?
> > > >  ex
> > > >       <html:options collection="Roles" property="name" /
> > > >
> > > >  For example, I have a collection of projects that are
> rendered by the
> > > >  <html:options tag.  I also have  some java script which updates a
> > > > project
> > > >  description box when the selection is changed.  The problem is
> > > >  when the page
> > > >  is first rendered, the two don't always match up.  I initialize the
> > > >  description box to the first item in the collection, but the
> > > >  select doesn't
> > > >  always choose the first item.
> > > >
> > > >  Thanks
> > > >  D
> > > >
> > >
>
>
>
>
>
>
>

Reply via email to