You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Scott Van Wart <sc...@indosoft.com> on 2006/07/21 23:54:28 UTC
Problem with map-based property in ActionForm
I have an action form defined like this:
public MyForm extends ActionForm {
private Map<String, String> values = new TreeMap<String, String>();
public Map<String, String> getValues() { return this.values; }
public Set<String> getKeys() { return this.values.keySet(); }
}
and in my JSP,
<c:forEach item="key" items="${myForm.keys}">
<html:multibox property="values(${key})"
value="first">First</html:multibox>
<html:multibox property="values(${key})"
value="second">Second</html:multibox>
<!-- ... -->
</c:forEach>
When I access the page, I get the following error:
"No getter method available for property permissions(1) for bean under
name org.apache.struts.taglib.html.BEAN"
Is this the right way to access map properties in a bean? Any ideas?
Thanks,
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with map-based property in ActionForm
Posted by Scott Van Wart <sc...@indosoft.com>.
(see my previous post)
Doesn't seem to work (since html:multibox won't use anything but the
bean declared by <html:form>). I think my main issue is the difference
between a bean declared directly (jsp:useBean) and one instantiated from
<html:form>. I guess I need to do some more doc reading to figure out
how to handle this, maybe with nested beans.
Thanks,
Scott
Dean, Michael wrote:
> Scott:
>
> See: http://struts.apache.org/1.2.9/faqs/indexedprops.html
>
> I think it remains for you to provide a method a la:
>
> public Object getKey(String key) {
> return values.get(key);
> }
>
> Regards,
> M
>
> -----Original Message-----
> From: Scott Van Wart [mailto:scott@indosoft.com]
> Sent: Friday, July 21, 2006 2:54 PM
> To: Struts Users Mailing List
> Subject: Problem with map-based property in ActionForm
>
> I have an action form defined like this:
>
> public MyForm extends ActionForm {
> private Map<String, String> values = new TreeMap<String, String>();
> public Map<String, String> getValues() { return this.values; }
> public Set<String> getKeys() { return this.values.keySet(); }
> }
>
> and in my JSP,
>
> <c:forEach item="key" items="${myForm.keys}">
> <html:multibox property="values(${key})"
> value="first">First</html:multibox>
> <html:multibox property="values(${key})"
> value="second">Second</html:multibox>
> <!-- ... -->
> </c:forEach>
>
> When I access the page, I get the following error:
>
> "No getter method available for property permissions(1) for bean under
> name org.apache.struts.taglib.html.BEAN"
>
> Is this the right way to access map properties in a bean? Any ideas?
>
> Thanks,
> Scott
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with map-based property in ActionForm
Posted by Scott Van Wart <sc...@indosoft.com>.
Hmm... I tried a number of variations. The example in the documentation
you listed seems to include the bean as <jsp:useBean.../> as opposed to
me implicitly using the myForm bean declared by <html:form action...>.
I noticed the error message mentions
'org.apache.struts.taglib.html.BEAN' rather than the MyForm class. The
variations I tried included "getKey( String key )", and "getValues(
String key )", but neither worked.
I'm going to try something a little different to isolate the mapped
property. Rather than accessing the property directly I'll try
extracting the map first:
<c:set var="values" value="${myForm.values}" />
Thanks for the info though, very valuable. I think the problem with my
last idea was the whole form->map->key which might need to be shortened
to form->key, but I'll let you know how I make out.
Thanks,
Scott
Dean, Michael wrote:
> Scott:
>
> See: http://struts.apache.org/1.2.9/faqs/indexedprops.html
>
> I think it remains for you to provide a method a la:
>
> public Object getKey(String key) {
> return values.get(key);
> }
>
> Regards,
> M
>
> -----Original Message-----
> From: Scott Van Wart [mailto:scott@indosoft.com]
> Sent: Friday, July 21, 2006 2:54 PM
> To: Struts Users Mailing List
> Subject: Problem with map-based property in ActionForm
>
> I have an action form defined like this:
>
> public MyForm extends ActionForm {
> private Map<String, String> values = new TreeMap<String, String>();
> public Map<String, String> getValues() { return this.values; }
> public Set<String> getKeys() { return this.values.keySet(); }
> }
>
> and in my JSP,
>
> <c:forEach item="key" items="${myForm.keys}">
> <html:multibox property="values(${key})"
> value="first">First</html:multibox>
> <html:multibox property="values(${key})"
> value="second">Second</html:multibox>
> <!-- ... -->
> </c:forEach>
>
> When I access the page, I get the following error:
>
> "No getter method available for property permissions(1) for bean under
> name org.apache.struts.taglib.html.BEAN"
>
> Is this the right way to access map properties in a bean? Any ideas?
>
> Thanks,
> Scott
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Problem with map-based property in ActionForm
Posted by "Dean, Michael" <Mi...@courts.wa.gov>.
Scott:
See: http://struts.apache.org/1.2.9/faqs/indexedprops.html
I think it remains for you to provide a method a la:
public Object getKey(String key) {
return values.get(key);
}
Regards,
M
-----Original Message-----
From: Scott Van Wart [mailto:scott@indosoft.com]
Sent: Friday, July 21, 2006 2:54 PM
To: Struts Users Mailing List
Subject: Problem with map-based property in ActionForm
I have an action form defined like this:
public MyForm extends ActionForm {
private Map<String, String> values = new TreeMap<String, String>();
public Map<String, String> getValues() { return this.values; }
public Set<String> getKeys() { return this.values.keySet(); }
}
and in my JSP,
<c:forEach item="key" items="${myForm.keys}">
<html:multibox property="values(${key})"
value="first">First</html:multibox>
<html:multibox property="values(${key})"
value="second">Second</html:multibox>
<!-- ... -->
</c:forEach>
When I access the page, I get the following error:
"No getter method available for property permissions(1) for bean under
name org.apache.struts.taglib.html.BEAN"
Is this the right way to access map properties in a bean? Any ideas?
Thanks,
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org