You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dani <mc...@wanadoo.es> on 2003/04/15 11:24:16 UTC
selecting an option - how to?
I have the code below:
<td width="100%" class="tableinfo">
<select name="zonas_codigo" size="1" class="formulario">
<logic:iterate id="listaZonas" name="listaZonas"
scope="request">
<option value="<bean:write name="listaZonas"
property="codigo"/>"><bean:write name="listaZonas"
property="nombre"/></option>
</logic:iterate>
</select>
</td>
I want to select (with SELECTED html label) an option making a comparison
with the option code saved in the request.
How can i do that? Must I use bean:write bundle property ?? I can't find any
reference about my problem in the documentation. Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: selecting an option - how to?
Posted by David Chelimsky <da...@chelimsky.org>.
Dani,
I've not tried to select a single option like this, but I did select
multiple options from a multi-select box using the struts form tags:
<html:form ...>
<bean:define id="options" name="myForm" property="options"
type="java.util.Collection" />
<html:select
multiple="true"
property="selectedOptions"
size="15"
>
<html:options collection="options" property="id"
labelProperty="name"/>
</html:select>
</html:form>
In my ActionForm, I built up a List of options with getId() and
getName() methods. Then I built an Integer[] of selectedOptions that
correspond to the getId() method on each option. I'm sure you could do
the same thing w/ an Integer[] of length 1. Just remove the
multiple="true" and size="15" from the <html:select> tag and you should
be good to go.
There's probably a better way, but this should work.
David
Dani wrote:
>I have the code below:
>
><td width="100%" class="tableinfo">
> <select name="zonas_codigo" size="1" class="formulario">
> <logic:iterate id="listaZonas" name="listaZonas"
>scope="request">
> <option value="<bean:write name="listaZonas"
>property="codigo"/>"><bean:write name="listaZonas"
>property="nombre"/></option>
> </logic:iterate>
> </select>
> </td>
>
>
>I want to select (with SELECTED html label) an option making a comparison
>with the option code saved in the request.
>
>How can i do that? Must I use bean:write bundle property ?? I can't find any
>reference about my problem in the documentation. Thanks
>
>
>---------------------------------------------------------------------
>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
Re: selecting an option - how to?
Posted by Brian McSweeney <br...@aurium.net>.
Not sure exactly what you are talking about but if you want to
have option values and labels you can use the struts
<html:options> using the "property" and the "labelProperty" parameters.
where property corresponds to the option value and labelProperty
corresponds to what is displayed.
hth,
brian
----- Original Message -----
From: "Dani" <mc...@wanadoo.es>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, April 15, 2003 10:24 AM
Subject: selecting an option - how to?
> I have the code below:
>
> <td width="100%" class="tableinfo">
> <select name="zonas_codigo" size="1" class="formulario">
> <logic:iterate id="listaZonas" name="listaZonas"
> scope="request">
> <option value="<bean:write name="listaZonas"
> property="codigo"/>"><bean:write name="listaZonas"
> property="nombre"/></option>
> </logic:iterate>
> </select>
> </td>
>
>
> I want to select (with SELECTED html label) an option making a comparison
> with the option code saved in the request.
>
> How can i do that? Must I use bean:write bundle property ?? I can't find
any
> reference about my problem in the documentation. Thanks
>
>
> ---------------------------------------------------------------------
> 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