You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mohan Radhakrishnan <Mo...@hclcomnet.co.in> on 2002/09/26 12:29:35 UTC

Value selection

Hi,
   Is it possible to display these values from a bean ? I have two sets of
methods according to the bean spec., one dealing with a java.util.Collection
and the other with a single value.


<SELECT class="list" multiple size=2 name=applications>
		<OPTION value=ALL> ALL </OPTION>
		<OPTION value='1' selected>Application1</OPTION>
		<OPTION value='2'>Application2</OPTION>
		<OPTION value='3'>Application3</OPTION>

 The selected values should go back into the same bean. Do I have to use a
'ActionForm' and populate my DTO from it? Will the bean have the selected
values automatically ?

 The suggested answer http://www.husted.com/struts/tips/006.html .....I
didn't understand this.
bye,
Mohan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Value selection

Posted by Robert Taylor <rt...@mulework.com>.
Mohan,

One way to do this is to have your action form contain the Collection of
options which you wish to display and an array of Strings which represent
the values selected by the user. The Collection of options could be a
collection of LabelValue beans. Using your example we would have the
following in the action form:

Collection applicationOptions;
String[] applications;

You could use the following syntax to render your application options:

<html:select property="applications" multiple="true" size="2" >
<html:optionsCollection property="applicationOptions" label="label"
value="value"/>
</html:select>


If applicationOptions doesn't change over the life of the application, then
you could initialize this collection at application start up  and place it
in the ServletContext where it would be available to all users. If you do
this there a a couple ways in which you could retrieve them.

1. You could have a set up action populate the action form with the
applicationOptions that exist in the ServletContext. This way you wouldn't
have to manage a separate attribute key for the applicationOptions.

2. You could simply use a separate attribute key to store and retrieve the
applicationOptions from the appropriate scope.

robert

> -----Original Message-----
> From: Mohan Radhakrishnan [mailto:MohanR@hclcomnet.co.in]
> Sent: Thursday, September 26, 2002 6:30 AM
> To: 'Struts Users Mailing List'
> Subject: Value selection
>
>
> Hi,
>    Is it possible to display these values from a bean ? I have two sets of
> methods according to the bean spec., one dealing with a
> java.util.Collection
> and the other with a single value.
>
>
> <SELECT class="list" multiple size=2 name=applications>
> 		<OPTION value=ALL> ALL </OPTION>
> 		<OPTION value='1' selected>Application1</OPTION>
> 		<OPTION value='2'>Application2</OPTION>
> 		<OPTION value='3'>Application3</OPTION>
>
>  The selected values should go back into the same bean. Do I have to use a
> 'ActionForm' and populate my DTO from it? Will the bean have the selected
> values automatically ?
>
>  The suggested answer http://www.husted.com/struts/tips/006.html .....I
> didn't understand this.
> bye,
> Mohan
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>