You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alok Garg <al...@direct2s.com> on 2002/10/28 05:31:59 UTC
Using tag
Hello,
I am facing a problem using <html:options> tag.
The case:
1) I have a Hashtable map which contain an Id (java.lang.Integer) as the Key and Description (String) as the value.
2) I have to iterate this Hashtable and display the values in a select box.
Please guide me with the above problem
Thanks
Alok
Re: Using tag
Posted by Umberto Nicoletti <un...@prometeo.it>.
On Mon, 2002-10-28 at 09:31, Alok Garg wrote:
> Hello,
> I am facing a problem using <html:options> tag.
> The case:
> 1) I have a Hashtable map which contain an Id (java.lang.Integer) as the Key and Description (String) as the value.
>
> 2) I have to iterate this Hashtable and display the values in a select box.
>
> Please guide me with the above problem
>
This worked for me:
<html:options collection="YOUR-HASHMAP-HERE" property="value"
labelProperty="key"/>
I found that reading the source for taglibs is much more interesting and
provides much more valuable info than reading the docs...
Use the source...
Umberto
> Thanks
> Alok
--
Umberto Nicoletti
unicoletti@prometeo.it | Tel. +390415701366
"We'll try to make different mistakes this time." - Larry Wall
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Using tag
Posted by Derek Lin <de...@hotmail.com>.
Perhaps my code doesn't really apply to what you are trying to do. I my
code, countries is an array of Country objects. A vectory of Country
objects will work, too.
I am not sure about a vectory of hashmap, though. (But it looks like you
are just using hashmap alone. I don't think that will work. It has to be
an indexed object) Maybe someone who has done it can help better. Sorry
for any confusions.
-- Derek
----- Original Message -----
From: "Alok Garg" <al...@direct2s.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, October 27, 2002 9:50 PM
Subject: Re: Using <html:Options > tag
> Hello Derek,
> Thanks for the reply, I tried using the code sinnpet that u have send, but
I
> am getting the following error::
>
> javax.servlet.jsp.JspException: Cannot create iterator for 1=Beauty
> at
> org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:448)
> at org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:236)
>
> where 1 is the Key of the Hashtable which is Integer
> and "beauty" is the Value of the Hashtable.
>
> Thanks
> Alok Garg
> ----- Original Message -----
> From: "Derek Lin" <de...@hotmail.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Monday, October 28, 2002 10:48 AM
> Subject: Re: Using <html:Options > tag
>
>
> > Here is my select population code:
> >
> > <td class="formItem">
> > <logic:present name="countries">
> > <html:select property="companyCountry" size="1" value="US">
> > <html:options collection="countries" property="code"
> > labelProperty="country" />
> > </html:select>
> > </logic:present>
> > <logic:notPresent name="countries">
> > <html:select property="companyCountry" size="1">
> > <option value="US">UNITED STATES</option>
> > </html:select>
> > </logic:notPresent>
> >
> > </td>
> > -- Derek
> > ----- Original Message -----
> > From: "Alok Garg" <al...@direct2s.com>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Sunday, October 27, 2002 8:31 PM
> > Subject: Using <html:Options > tag
> >
> >
> > Hello,
> > I am facing a problem using <html:options> tag.
> > The case:
> > 1) I have a Hashtable map which contain an Id (java.lang.Integer) as
the
> > Key and Description (String) as the value.
> >
> > 2) I have to iterate this Hashtable and display the values in a select
> box.
> >
> > Please guide me with the above problem
> >
> > Thanks
> > Alok
> >
> >
> > --
> > 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>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Using tag
Posted by Alok Garg <al...@direct2s.com>.
Hello Derek,
Thanks for the reply, I tried using the code sinnpet that u have send, but I
am getting the following error::
javax.servlet.jsp.JspException: Cannot create iterator for 1=Beauty
at
org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:448)
at org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:236)
where 1 is the Key of the Hashtable which is Integer
and "beauty" is the Value of the Hashtable.
Thanks
Alok Garg
----- Original Message -----
From: "Derek Lin" <de...@hotmail.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, October 28, 2002 10:48 AM
Subject: Re: Using <html:Options > tag
> Here is my select population code:
>
> <td class="formItem">
> <logic:present name="countries">
> <html:select property="companyCountry" size="1" value="US">
> <html:options collection="countries" property="code"
> labelProperty="country" />
> </html:select>
> </logic:present>
> <logic:notPresent name="countries">
> <html:select property="companyCountry" size="1">
> <option value="US">UNITED STATES</option>
> </html:select>
> </logic:notPresent>
>
> </td>
> -- Derek
> ----- Original Message -----
> From: "Alok Garg" <al...@direct2s.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Sunday, October 27, 2002 8:31 PM
> Subject: Using <html:Options > tag
>
>
> Hello,
> I am facing a problem using <html:options> tag.
> The case:
> 1) I have a Hashtable map which contain an Id (java.lang.Integer) as the
> Key and Description (String) as the value.
>
> 2) I have to iterate this Hashtable and display the values in a select
box.
>
> Please guide me with the above problem
>
> Thanks
> Alok
>
>
> --
> 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>
Re: Using tag
Posted by Derek Lin <de...@hotmail.com>.
Here is my select population code:
<td class="formItem">
<logic:present name="countries">
<html:select property="companyCountry" size="1" value="US">
<html:options collection="countries" property="code"
labelProperty="country" />
</html:select>
</logic:present>
<logic:notPresent name="countries">
<html:select property="companyCountry" size="1">
<option value="US">UNITED STATES</option>
</html:select>
</logic:notPresent>
</td>
-- Derek
----- Original Message -----
From: "Alok Garg" <al...@direct2s.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, October 27, 2002 8:31 PM
Subject: Using <html:Options > tag
Hello,
I am facing a problem using <html:options> tag.
The case:
1) I have a Hashtable map which contain an Id (java.lang.Integer) as the
Key and Description (String) as the value.
2) I have to iterate this Hashtable and display the values in a select box.
Please guide me with the above problem
Thanks
Alok
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>