You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Doug Thomas <do...@softechnics.com> on 2005/10/10 14:50:44 UTC

Select first in Options list

I have a Select element with several Options making up a selection list. The
Options are built dynamically from a database. After the list is built, I
want the first option in the list to be SELECTed. Every sample I've seen
assumes you know what's in the list and you know what option you want
selected, by name.

Any ideas on how to do this?

Doug



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Select first in Options list

Posted by Martin Gainty <mg...@hotmail.com>.
Doug
I think you are referring to the auditListCollection implementation of 
html:optionsCollection example illustrated at
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21506596.html
where
Bean.Property.value MUST MATCH the VALUE of the selected option
The only part you have to be concerned with is that you must retrieve the 
'bean' from auditListCollection via get("WhateverItemWasAdded")

in this case of the AuditSelectListItem if
auditListForm.selectedAudit.Value = "Audit G"
Then the last item added (Audit G) would be appear selected

I hope that helps you out
Martin-

----- Original Message ----- 
From: "Doug Thomas" <do...@softechnics.com>
To: "'Struts Users Mailing List'" <us...@struts.apache.org>; "'Martin 
Gainty'" <mg...@hotmail.com>
Sent: Monday, October 10, 2005 3:22 PM
Subject: RE: Select first in Options list


> Martin,
>
>>> the doc for <html:option> states...
>
> I'm using <html:optionsCollection name="auditListCollection" label="label"
> value="value" />, giving me a list of options. How to select one option 
> from
> this list (the first - always) is the question. I now have the first
> (default, or selected option value) in a session attribute that this JSP 
> can
> get hold of. How to use that info? Or, does this have to be done at the
> server in the Action class?
>
> Rajasekhar,
>
> If no option is SELECTED, then no default is specified. It does NOT 
> default
> to the first option in the list.
>
> Doug
>
> -----Original Message-----
> From: Martin Gainty [mailto:mgainty@hotmail.com]
> Sent: Monday, October 10, 2005 10:56 AM
> To: Struts Users Mailing List
> Subject: Re: Select first in Options list
>
> Doug-
> If you want specific items (options) pre-selected for your select control
> the doc for <html:option> states
> If the value of the corresponding bean property matches the specified 
> value,
>
> this option will be marked selected
> http://www.linuxforum.net/doc/tags.html#options1
> HTH,
> Martin-
> ----- Original Message ----- 
> From: <ra...@tcs.com>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Sent: Monday, October 10, 2005 9:15 AM
> Subject: Re: Select first in Options list
>
>
>>
>> Hi,
>>        Do not use "selected" for any option. By default automatically,
>> the first option will be selected and your purpose will be solved.
>>
>> Regards,
>> Rajasekhar Cherukuri
>>
>>
>>
>>
>> "Doug Thomas" <do...@softechnics.com>
>> 10/10/2005 06:20 PM
>> Please respond to
>> "Struts Users Mailing List" <us...@struts.apache.org>
>>
>>
>> To
>> "Struts MailList" <us...@struts.apache.org>
>> cc
>>
>> Subject
>> Select first in Options list
>>
>>
>>
>>
>>
>>
>> I have a Select element with several Options making up a selection list.
>> The
>> Options are built dynamically from a database. After the list is built, I
>> want the first option in the list to be SELECTed. Every sample I've seen
>> assumes you know what's in the list and you know what option you want
>> selected, by name.
>>
>> Any ideas on how to do this?
>>
>> Doug
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>> ForwardSourceID:NT00005B56
>>
>>
>> Notice: The information contained in this e-mail message and/or
>> attachments to it may contain confidential or privileged information. 
>> If
>
>> you are not the intended recipient, any dissemination, use, review,
>> distribution, printing or copying of the information contained in this
>> e-mail message and/or attachments to it are strictly prohibited.   If you
>> have received this communication in error, please notify us by reply
>> e-mail or telephone and immediately and permanently delete the message 
>> and
>
>> any attachments.  Thank you
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Select first in Options list

Posted by Doug Thomas <do...@softechnics.com>.
Martin,

>> the doc for <html:option> states...

I'm using <html:optionsCollection name="auditListCollection" label="label"
value="value" />, giving me a list of options. How to select one option from
this list (the first - always) is the question. I now have the first
(default, or selected option value) in a session attribute that this JSP can
get hold of. How to use that info? Or, does this have to be done at the
server in the Action class?

Rajasekhar,

If no option is SELECTED, then no default is specified. It does NOT default
to the first option in the list.

Doug

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Monday, October 10, 2005 10:56 AM
To: Struts Users Mailing List
Subject: Re: Select first in Options list

Doug-
If you want specific items (options) pre-selected for your select control 
the doc for <html:option> states
If the value of the corresponding bean property matches the specified value,

this option will be marked selected
http://www.linuxforum.net/doc/tags.html#options1
HTH,
Martin-
----- Original Message ----- 
From: <ra...@tcs.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Monday, October 10, 2005 9:15 AM
Subject: Re: Select first in Options list


>
> Hi,
>        Do not use "selected" for any option. By default automatically,
> the first option will be selected and your purpose will be solved.
>
> Regards,
> Rajasekhar Cherukuri
>
>
>
>
> "Doug Thomas" <do...@softechnics.com>
> 10/10/2005 06:20 PM
> Please respond to
> "Struts Users Mailing List" <us...@struts.apache.org>
>
>
> To
> "Struts MailList" <us...@struts.apache.org>
> cc
>
> Subject
> Select first in Options list
>
>
>
>
>
>
> I have a Select element with several Options making up a selection list.
> The
> Options are built dynamically from a database. After the list is built, I
> want the first option in the list to be SELECTed. Every sample I've seen
> assumes you know what's in the list and you know what option you want
> selected, by name.
>
> Any ideas on how to do this?
>
> Doug
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ForwardSourceID:NT00005B56
>
>
> Notice: The information contained in this e-mail message and/or 
> attachments to it may contain confidential or privileged information.   If

> you are not the intended recipient, any dissemination, use, review, 
> distribution, printing or copying of the information contained in this 
> e-mail message and/or attachments to it are strictly prohibited.   If you 
> have received this communication in error, please notify us by reply 
> e-mail or telephone and immediately and permanently delete the message and

> any attachments.  Thank you 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Select first in Options list

Posted by Martin Gainty <mg...@hotmail.com>.
Doug-
If you want specific items (options) pre-selected for your select control 
the doc for <html:option> states
If the value of the corresponding bean property matches the specified value, 
this option will be marked selected
http://www.linuxforum.net/doc/tags.html#options1
HTH,
Martin-
----- Original Message ----- 
From: <ra...@tcs.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Monday, October 10, 2005 9:15 AM
Subject: Re: Select first in Options list


>
> Hi,
>        Do not use "selected" for any option. By default automatically,
> the first option will be selected and your purpose will be solved.
>
> Regards,
> Rajasekhar Cherukuri
>
>
>
>
> "Doug Thomas" <do...@softechnics.com>
> 10/10/2005 06:20 PM
> Please respond to
> "Struts Users Mailing List" <us...@struts.apache.org>
>
>
> To
> "Struts MailList" <us...@struts.apache.org>
> cc
>
> Subject
> Select first in Options list
>
>
>
>
>
>
> I have a Select element with several Options making up a selection list.
> The
> Options are built dynamically from a database. After the list is built, I
> want the first option in the list to be SELECTed. Every sample I've seen
> assumes you know what's in the list and you know what option you want
> selected, by name.
>
> Any ideas on how to do this?
>
> Doug
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ForwardSourceID:NT00005B56
>
>
> Notice: The information contained in this e-mail message and/or 
> attachments to it may contain confidential or privileged information.   If 
> you are not the intended recipient, any dissemination, use, review, 
> distribution, printing or copying of the information contained in this 
> e-mail message and/or attachments to it are strictly prohibited.   If you 
> have received this communication in error, please notify us by reply 
> e-mail or telephone and immediately and permanently delete the message and 
> any attachments.  Thank you 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Select first in Options list

Posted by ra...@tcs.com.
Hi,
        Do not use "selected" for any option. By default automatically, 
the first option will be selected and your purpose will be solved.

Regards,
Rajasekhar Cherukuri




"Doug Thomas" <do...@softechnics.com> 
10/10/2005 06:20 PM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>


To
"Struts MailList" <us...@struts.apache.org>
cc

Subject
Select first in Options list






I have a Select element with several Options making up a selection list. 
The
Options are built dynamically from a database. After the list is built, I
want the first option in the list to be SELECTed. Every sample I've seen
assumes you know what's in the list and you know what option you want
selected, by name.

Any ideas on how to do this?

Doug



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


ForwardSourceID:NT00005B56 


Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information.   If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited.   If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments.  Thank you