You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Caroline Jen <ji...@yahoo.com> on 2004/06/09 04:30:13 UTC

I try to create a drop down menu as follow:

<html:select size="1" name="sort"
onchange="document.forms[4].elements[2].focus()">
<html:options collection="SORT" property="value"
labelProperty="label"/>
</html:select>

I am able to disply the menu.  

I want one of the options to be selected by default. 
Therefore, I want to type SELECTED somewhere.  How do
I do it?


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re:

Posted by nikhil walvekar <wa...@yahoo.co.in>.
Hi,
if your collection contains only options which are to be shown not blank option something like this.
option[0]="option0";
option[1]="option1";
option[2]="option2";
 
Then always first option will be selected.
now if you want some another option to be selected then 
you have to provide value attribute for html:select tag
If you specify some another value which is not in that collection then it will select first value in collection.
 
 
Nikhil

Shailender Jain <sh...@teleatlas.com> wrote:
Hi All,

If the someBean.getDefault() has some values which is not there in the
collection SORT then the problem
is that the select tag will display some value from the collection not the
value from someBean.getDefault().

I faced this situation when i had to display a blank combo box and the
collection having the data of the employee names.


Any idea on how to handle this?



Shailender Jain

nikhil walvekar wrote:

> Hi,
>
> for html:select tag you can specify value
> there you can write your default value from some bean
>
> > onchange="document.forms[4].elements[2].focus()" value="">
> > labelProperty="label"/>
> 
>
> Nikhil.
>
> Caroline Jen wrote:
> I try to create a drop down menu as follow:
>
> > onchange="document.forms[4].elements[2].focus()">
> > labelProperty="label"/>
> 
>
> I am able to disply the menu.
>
> I want one of the options to be selected by default.
> Therefore, I want to type SELECTED somewhere. How do
> I do it?
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> Nikhil
>
> Yahoo! India Matrimony: Find your partner online.


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

Yahoo! India Matrimony: Find your partner online.

Re:

Posted by Shailender Jain <sh...@teleatlas.com>.
Hi All,

         If the someBean.getDefault() has some values which is not there in the
collection SORT then the problem
         is that  the select tag will display some value from the collection not the
value from someBean.getDefault().

         I faced this situation when i had to display a blank combo box and the
collection having the data of the employee names.


         Any idea on how to handle this?



Shailender Jain

nikhil walvekar wrote:

> Hi,
>
> for html:select tag you can specify value
> there you can write your default value from some bean
>
> <html:select size="1" name="sort"
> onchange="document.forms[4].elements[2].focus()" value="<%= someBean.getDefault()%>">
> <html:options collection="SORT" property="value"
> labelProperty="label"/>
> </html:select>
>
> Nikhil.
>
> Caroline Jen <ji...@yahoo.com> wrote:
> I try to create a drop down menu as follow:
>
> <html:select size="1" name="sort"
> onchange="document.forms[4].elements[2].focus()">
> <html:options collection="SORT" property="value"
> labelProperty="label"/>
> </html:select>
>
> I am able to disply the menu.
>
> I want one of the options to be selected by default.
> Therefore, I want to type SELECTED somewhere.  How do
> I do it?
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> Nikhil
>
> Yahoo! India Matrimony: Find your partner online.


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


RE:

Posted by Guillermo Meyer <gm...@interbanking.com.ar>.
Also you can set the "sort" value before forwarding to the JSP (ie in
the previous action)
1) Action prepares the SORT collection and sets it in the request
2) Action sets default value to "sort" attribute only if "sort" has no
value (so setting the default)
3) Action forwards to JSP
4) JSP renders html:select and html:options. As sort" as a value (set in
the action) the matching option value will be rendered as SELECTED.

Cheers.
Guillermo.

-----Original Message-----
From: nikhil walvekar [mailto:walvekarnikhil@yahoo.co.in] 
Sent: MiƩrcoles, 09 de Junio de 2004 06:07 a.m.
To: Struts Users Mailing List
Subject: Re: <html:options .... >


Hi,
 
for html:select tag you can specify value
there you can write your default value from some bean
 
<html:select size="1" name="sort"
onchange="document.forms[4].elements[2].focus()" value="<%=
someBean.getDefault()%>"> <html:options collection="SORT"
property="value" labelProperty="label"/> </html:select>
 
Nikhil.

Caroline Jen <ji...@yahoo.com> wrote:
I try to create a drop down menu as follow:

<html:select size="1" name="sort"
onchange="document.forms[4].elements[2].focus()">
<html:options collection="SORT" property="value" labelProperty="label"/>
</html:select>

I am able to disply the menu.  

I want one of the options to be selected by default. 
Therefore, I want to type SELECTED somewhere.  How do
I do it?


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


 
Nikhil  












Yahoo! India Matrimony: Find your partner online.

NOTA DE CONFIDENCIALIDAD
Este mensaje (y sus anexos) es confidencial, esta dirigido exclusivamente a las personas direccionadas en el mail y puede contener informacion (i)de propiedad exclusiva de Interbanking S.A. o (ii) amparada por el secreto profesional. Cualquier opinion en el contenido, es exclusiva de su autor y no representa necesariamente la opinion de Interbanking S.A. El acceso no autorizado, uso, reproduccion, o divulgacion esta prohibido. Interbanking S.A no asumira responsabilidad ni obligacion legal alguna por cualquier informacion incorrecta o alterada contenida en este mensaje. Si usted ha recibido este mensaje por error, le rogamos tenga la amabilidad de destruirlo inmediatamente junto con todas las copias del mismo, notificando al remitente. No debera utilizar, revelar, distribuir, imprimir o copiar este mensaje ni ninguna de sus partes si usted no es el destinatario. Muchas gracias.



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


Re:

Posted by nikhil walvekar <wa...@yahoo.co.in>.
Hi,
 
for html:select tag you can specify value
there you can write your default value from some bean
 
<html:select size="1" name="sort"
onchange="document.forms[4].elements[2].focus()" value="<%= someBean.getDefault()%>">
<html:options collection="SORT" property="value"
labelProperty="label"/>
</html:select>
 
Nikhil.

Caroline Jen <ji...@yahoo.com> wrote:
I try to create a drop down menu as follow:

<html:select size="1" name="sort"
onchange="document.forms[4].elements[2].focus()">
<html:options collection="SORT" property="value"
labelProperty="label"/>
</html:select>

I am able to disply the menu.  

I want one of the options to be selected by default. 
Therefore, I want to type SELECTED somewhere.  How do
I do it?


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


 
Nikhil  












Yahoo! India Matrimony: Find your partner online.