struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Natalie D Rassmann <natalie.d.rassm...@lmco.com>
Subject Re: html:option - is there a selected option attribute?
Date Tue, 24 Jun 2003 09:35:00 GMT
Steve,

Thank you VERY much.  I will be sure to take a look; half the battle is
finding examples.

Natalie

Steve Raeburn wrote:

> Natalie,
>
> If it would help, I've put together an example application
> (http://www.ninsky.com/struts) that shows most of the basic tags in
> action.
> It actually came about after a discussion about options examples, so
> there
> may be something you could use.
>
> It's available as a WAR file that you can deploy directly to your
> servlet
> container and includes viewable source so you can cut-and-paste any
> examples
> that might do what you need.
>
> Another useful source of examples is the excercise-taglib application
> which
> is included in the struts distribution. It's got more comprehensive
> coverage
> of the tags than mine but is designed to test the tags rather than be
> easy
> to understand for someone new to Struts.
>
> HTH
>
> Steve
>
> > -----Original Message-----
> > From: Rassmann, Natalie D [mailto:natalie.d.rassmann@lmco.com]
> > Sent: June 23, 2003 11:43 AM
> > To: Struts Users Mailing List
> > Subject: Re: html:option - is there a selected option attribute?
> >
> >
> > Wendy,
> >
> > You have been very helpful.  This is my first STRUTS app and I seem
> to
> > stumble the most on getting these tags to work.  I have not found
> any real
> > documentation examples to help me.  At any rate, I tried to use
> > the options
> > collection tag and I had no success.  It was one error after
> another.  I
> > finally got the lists to display as a drop down using the JSTL
> > tag forEach.
> >
> >
> > This is what my code looked like when I was trying to use the
> options
> > collection tag:
> >
> >
> >  <html-el:select name="reviewRecordForm" property="csci.options">
> >      <html-el:options collection="${reviewRecordForm.map.csci}"
> > property="optionId" labelProperty="optionLabel"/>
> >   </html-el:select>
> >
> >
> > After reading what you wrote, I think I should try the following to
> get it
> > to work:
> >
> >
> >  <html-el:select name="reviewRecordForm" property="csci">
> >      <html-el:options
> > collection="${reviewRecordForm.map.csci.options}"property="optionId"
>
> > labelProperty="optionLabel"/>
> >   </html-el:select>
> >
> >
> > csci is another property in my form bean which is the same type as
> > baseline.....  In the properties field of the select tag I used the
> > collection instead of the actual form bean property.  I think
> > maybe this was
> > my problem.  I am going to try it and see what happens.
> >
> >
> > Do you think I am on the right track??
> >
> >
> > Thanks for your help,
> >
> >
> > Natalie
> >
> >
> > Wendy Smoak wrote:
> >
> >
> > Natalie wrote:
> > > In my Action's execute method, I do a beanutils.copyProperties
> > to copy the
> >
> >
> >
> > > dto (data from DB) into my form.  So, my form bean property is
> > already set
> >
> >
> >
> > > to the list. This list is used to build the select list drop
> > down box in
> > my jsp.
> >
> >
> > The entire contents of the drop down is a different thing than the
> single
> > item from that list that the user has selected.  I don't store
> > the lists of
> > items in my Form bean, but YMMV.
> >
> >
> > You don't have to do the iteration with c:forEach, the select tag
> > will do it
> >
> > for you.
> >
> >
> > Here's one of mine:
> > <html-el:select property="purpose">
> >  <html-el:options collection="reminderPurposes" property="key"
> > labelProperty="value"/>
> > </html-el:select>
> >
> >
> > Where 'reminderPurposes' is a Collection sitting in Application
> scope.
> >
> >
> > If I wanted to "pre-select" a certain item, I might (in the
> > Action's execute
> >
> > method) do:
> > ( (DynaActionForm) form ).set( "purpose", "GI" );
> >
> >
> > Instead, I just do this:
> >    BeanUtils.copyProperties( dvForm, contact );
> > and since the DTO and the form both have a 'purpose' property, the
> value
> > gets copied from the DTO (contact in this case) to the form.
> >
> >
> > You ask what you're supposed to set 'baseline' to.  I thought you
> were
> > originally asking how to pre-select a certain value before the form
> is
> > displayed for the first time.  If you don't have a value in mind,
> > then don't
> >
> > set it to anything.
> >
> >
> > However, most of the problem seems to be that you're working too
> hard...
> > Struts handles most of this, the iteration over a Collection,
> > pre-selecting
> > the right item, magically behind the scenes, and you don't have to
> do
> > anything.
> >
> >
> > --
> > Wendy Smoak
> > Applications Systems Analyst, Sr.
> > Public Affairs, Information Resources Management
> > Arizona State University, Tempe AZ
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org

Mime
View raw message