You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by otisg <ot...@ureach.com> on 2003/05/20 19:13:36 UTC
Map of Beans and html:options - problem
Hello,
I am having trouble using <html:select> and <html:options> with
a Map (TreeMap) of Java Beans. I am using a recent 1.1RC1 from
maybe a month ago.
In my Action class I stick a Map into a request:
request.setAttribute("gradeMap, myMap);
This Map has Longs for keys and instances of my Java Bean class
'Grade' as values.
My 'Grade' Java Bean has a public getName() method and also
inherits a public getID() method from its parent class.
In my JSP I am trying to render this Map in the pull-down menu:
<html:select property="gradeSid">
<html:options collection="gradeMap"
property="ID"
labelProperty="name"/>
</html:select>
This gives me the following error:
No getter method available for property ID for bean under name
gradeMap' javax.servlet.jsp.JspException: No getter method
available for property ID
Any idea why?
For sanity, I looped through the Map to ensure the contents is
correct:
for (java.util.Iterator iter = gMap.entrySet().iterator();
iter.hasNext(); )
{
java.util.Map.Entry me = (java.util.Map.Entry) iter.next();
Long key = (Long) me.getKey();
Grade g = (Grade) me.getValue();
System.out.println("G ID: " + g.getID());
System.out.println("G NAME: " + g.getName());
}
Am I using <html:select> and <html:options> incorrectly?
Thanks,
Otis
________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Map of Beans and html:options - problem
Posted by Caroline Holanda <sp...@yahoo.com>.
I guess it is related to JavaBeans properties rules.
Their identifier should start with lower case. So,
your "ID" property should be changed to "id".
Caroline
--- otisg <ot...@ureach.com> escreveu: > Hello,
>
> I am having trouble using <html:select> and
> <html:options> with
> a Map (TreeMap) of Java Beans. I am using a recent
> 1.1RC1 from
> maybe a month ago.
>
> In my Action class I stick a Map into a request:
>
> request.setAttribute("gradeMap, myMap);
>
> This Map has Longs for keys and instances of my Java
> Bean class
> 'Grade' as values.
>
> My 'Grade' Java Bean has a public getName() method
> and also
> inherits a public getID() method from its parent
> class.
>
> In my JSP I am trying to render this Map in the
> pull-down menu:
>
> <html:select property="gradeSid">
> <html:options collection="gradeMap"
> property="ID"
> labelProperty="name"/>
> </html:select>
>
>
> This gives me the following error:
>
> No getter method available for property ID for bean
> under name
> gradeMap' javax.servlet.jsp.JspException: No getter
> method
> available for property ID
>
> Any idea why?
>
> For sanity, I looped through the Map to ensure the
> contents is
> correct:
>
> for (java.util.Iterator iter =
> gMap.entrySet().iterator();
> iter.hasNext(); )
> {
> java.util.Map.Entry me = (java.util.Map.Entry)
> iter.next();
> Long key = (Long) me.getKey();
> Grade g = (Grade) me.getValue();
> System.out.println("G ID: " + g.getID());
> System.out.println("G NAME: " + g.getName());
> }
>
> Am I using <html:select> and <html:options>
> incorrectly?
>
> Thanks,
> Otis
>
>
> ________________________________________________
> Get your own "800" number
> Voicemail, fax, email, and a lot more
> http://www.ureach.com/reg/tag
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
>
=====
******************************
Cuide das pessoas que vc ama!
Elas são presentes de Deus!
_______________________________________________________________________
Yahoo! Mail
O melhor e-mail gratuito da internet: 6MB de espaço, antivírus, acesso POP3, filtro contra spam.
http://br.mail.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org