You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andy Kriger <ak...@greaterthanone.com> on 2003/01/24 16:26:24 UTC
how do i use a mapped value in bean:write?
I am trying to use mapped values in bean:write but not having any success.
* I have a bean named theBean in the session and it defines a method
public Item getItem() { ... }
* Item defines a method that returns a Map
public java.util.Map get Properties() { ... }
* The map contains key value pairs
e.g. prop1
So, I want to get the value prop1 using bean:write
<bean:write name="theBean" property="item.properties(prop1)"
scope="session"/>
I get a Servlet Exception when I try to load the page
java.lang.IllegalArgumentException: object is not an instance of declaring
class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.commons.beanutils.PropertyUtils.getMappedProperty(PropertyUtils.j
ava:626)
at
org.apache.commons.beanutils.PropertyUtils.getMappedProperty(PropertyUtils.j
ava:555)
at
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.j
ava:747)
at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:78
0)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:728)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:290)
I've been trying different permutations of single/double quotes around the
property name without success. Can anyone point me in the right direction?
thx
a
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: how do i use a mapped value in bean:write?
Posted by Andy Kriger <ak...@greaterthanone.com>.
I want to followup to my own message since I finally found a solution to
this problem (after many postings with no response) and it might be of
interest to the community.
The BeanUtils lib was out-of-date and had fixed a bug around this. Updating
that solved the problem. Just a caveat - watch those dependent libraries,
the problem may be there and not in Struts or your code.
-a
-----Original Message-----
From: Andy Kriger [mailto:akriger@greaterthanone.com]
Sent: Friday, January 24, 2003 10:26
To: Struts Users Mailing List
Subject: how do i use a mapped value in bean:write?
I am trying to use mapped values in bean:write but not having any success.
* I have a bean named theBean in the session and it defines a method
public Item getItem() { ... }
* Item defines a method that returns a Map
public java.util.Map get Properties() { ... }
* The map contains key value pairs
e.g. prop1
So, I want to get the value prop1 using bean:write
<bean:write name="theBean" property="item.properties(prop1)"
scope="session"/>
I get a Servlet Exception when I try to load the page
java.lang.IllegalArgumentException: object is not an instance of declaring
class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.commons.beanutils.PropertyUtils.getMappedProperty(PropertyUtils.j
ava:626)
at
org.apache.commons.beanutils.PropertyUtils.getMappedProperty(PropertyUtils.j
ava:555)
at
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.j
ava:747)
at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:78
0)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:728)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:290)
I've been trying different permutations of single/double quotes around the
property name without success. Can anyone point me in the right direction?
thx
a
--
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>