RE: setting 'selected' in html:select

2002-03-18 Thread Maturo, Larry

All of Struts is two-way.  Wherever you 
expect to get back a value, just put a value
there to initialize it.  So, to preselect an
option, set the variable in your form you
pointed to in the Select tag with the value
you want preselected.  It's really that easy.

-- Larry Maturo
   [EMAIL PROTECTED]


-Original Message-
From: Struts Newsgroup [mailto:@[EMAIL PROTECTED]]
Sent: Saturday, March 16, 2002 8:40 PM
To: [EMAIL PROTECTED]
Subject: setting 'selected' in html:select


Subject: setting 'selected' in html:select
From: "blinky" <[EMAIL PROTECTED]>
 ===
This may seem a really basic question but can anyone show me how to preset a
value as selected in a struts  tag???

In the old 'cruddy' raw jsp world I'd loop through the collection until
finding the preset value and stick 'selected' into the option tag that
matched.

Seems I can't do that when using  - though I was expecting some neater
way would exist to handle it anyway??

Do I need to have another property in 'mybean' called 'selected' with
getters/setters
Or do I somehow preset the selection on the htm:select tag???.

Any help much appreciated

Regards,
Blinky



--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: setting 'selected' in html:select

2002-03-17 Thread @Basebeans.com

Subject: Re: setting 'selected' in html:select
From: "blinky" <[EMAIL PROTECTED]>
 ===
Jim,

Only question then is whether I could  invoke the action class prior to
initial display of the view (ie. view jsp is the first thing thats
displayed). I do have a servlet that fires initially for the entire
application but its running in application context.

I've since got around this by setting the actionform property as you said
but doing  it inside constructor of the actionform itself . I think this
means when the jsp is very first displayed it creates the actionform and so
sets the property

Thanks for your help.

Regards,
Blinky

"Jim Crossley" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> Set the formbean attribute that corresponds to the "property" value of
> the enclosing  tag.  If the value exists in the nested options
> somewhere, then the  tag will automatically add the "selected"
> attribute to the html output.
>
> This is normally done in the action class prior to forwarding to your
> view.
>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: setting 'selected' in html:select

2002-03-17 Thread Jim Crossley

Set the formbean attribute that corresponds to the "property" value of
the enclosing  tag.  If the value exists in the nested options
somewhere, then the  tag will automatically add the "selected"
attribute to the html output.

This is normally done in the action class prior to forwarding to your
view.

Struts Newsgroup (@Basebeans.com) <[EMAIL PROTECTED]> writes:

> Subject: setting 'selected' in html:select
> From: "blinky" <[EMAIL PROTECTED]>
>  ===
> This may seem a really basic question but can anyone show me how to preset a
> value as selected in a struts  tag???
> 
> In the old 'cruddy' raw jsp world I'd loop through the collection until
> finding the preset value and stick 'selected' into the option tag that
> matched.
> 
> Seems I can't do that when using  property="value" labelProperty="label"> - though I was expecting some neater
> way would exist to handle it anyway??
> 
> Do I need to have another property in 'mybean' called 'selected' with
> getters/setters
> Or do I somehow preset the selection on the htm:select tag???.
> 
> Any help much appreciated
> 
> Regards,
> Blinky
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

-- 
Jim Crossley
http://www.lads.com/~jim

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




setting 'selected' in html:select

2002-03-16 Thread @Basebeans.com

Subject: setting 'selected' in html:select
From: "blinky" <[EMAIL PROTECTED]>
 ===
This may seem a really basic question but can anyone show me how to preset a
value as selected in a struts  tag???

In the old 'cruddy' raw jsp world I'd loop through the collection until
finding the preset value and stick 'selected' into the option tag that
matched.

Seems I can't do that when using  - though I was expecting some neater
way would exist to handle it anyway??

Do I need to have another property in 'mybean' called 'selected' with
getters/setters
Or do I somehow preset the selection on the htm:select tag???.

Any help much appreciated

Regards,
Blinky



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>