You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gene Ge <ge...@hotmail.com> on 2002/08/27 12:00:14 UTC
problem with PropertyUtils.getProperty()
hello everyone;
I meet a problem please help me.
I have a action which forwards to a jsp file, some scripts of jsp are:
<html:text property="stature" size="16" maxlength="16"/>
...<html:text property="avoirdupois" size="16" maxlength="16"/>
...<html:text property="lEyesight" size="16" maxlength="16"/>
...<html:text property="rEyesight" size="16" maxlength="16"/>
...
when invoked, I got a Exception:
javax.servlet.jsp.JspException: No getter method for property lEyesight of
bean
org.apache.struts.taglib.html.BEAN
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:716)
at
org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.ja
va:192)
at
org.apache.jsp.EditHealthInfo$jsp._jspService(EditHealthInfo$jsp.java
:413)
so I trid to invoked the formbean's "getLEyesight" method, it gave the right
out
put which proved that "lEyesight" property's getter really exist.
then I delete the
<html:text property="lEyesight" size="16" maxlength="16"/>
<html:text property="rEyesight" size="16" maxlength="16"/>
from my jsp script(both of lEyesight and rEyesight will cause the problem)
and t
his time it work well.
I was confused so I check the source code of struts and found the problem
existe
d in the
org.apache.commons.beanutils.PropertyUtils.getProperty(bean, property)
so I added this operation in my action like this:
healform=new HealthInfoForm(gm.getHealthInfoData());//get a form
System.out.println("invoke in action:"+healform.getLEyesight());//invoke
dir
ectly
try{
String
leye=(String)org.apache.commons.beanutils.PropertyUtils.getPr
operty(healform,"lEyesight");
System.out.println("leyesight="+leye);//try struts way to get
proper
ty
}
catch(Exception e){
System.out.println("exception when do getProperty:"+e);
e.printStackTrace();
}
session.setAttribute(mapping.getAttribute(),healform);
the result is:
15:27:31,115 INFO [STDOUT] invoke in action:5.0
15:27:31,165 INFO [STDOUT] exception when do
getProperty:java.lang.NoSuchMethod
Exception: Unknown property 'lEyesight'
15:27:31,095 ERROR [STDERR] java.lang.NoSuchMethodException: Unknown
property 'l
Eyesight'
15:27:31,095 ERROR [STDERR] at
org.apache.commons.beanutils.PropertyUtils.ge
tSimpleProperty(PropertyUtils.java:1151)
15:27:31,095 ERROR [STDERR] at
org.apache.commons.beanutils.PropertyUtils.ge
tNestedProperty(PropertyUtils.java:751)
15:27:31,095 ERROR [STDERR] at
org.apache.commons.beanutils.PropertyUtils.ge
tProperty(PropertyUtils.java:780)
15:27:31,095 ERROR [STDERR] at
com.bit.job.actions.EditHealthInfoAction.exec
ute(EditHealthInfoAction.java:58)
so it can be invoked directly but can not through PropertyUtils?
I tried to find something in the PropertyUtils' source code, but for my
limit kn
owledges I couldn't find anything.
thanks a lot.
best regards!
Gene
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: problem with PropertyUtils.getProperty()
Posted by John Raley <jb...@mindspring.com>.
Hi Gene,
You're getting hose by JavaBeans capitalization rules. If the second
letter of the property is upper-cased, the first letter will not get
lower-cased. So try property='LEyesite' See
java.beans.Introspector.decapitalize() for the gory details.
HTH,
John
--
Check it out: Map -> JavaBean
http://dynclass.sourceforge.net/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: problem with PropertyUtils.getProperty()
Posted by Andrew Hill <an...@gridnode.com>.
At first glance, 'twould appear to be the fact that your property has a
capitalised letter as its second character. Should it be that your getter is
named getLEyesight(), the propertyUtils assumes based on its rather dodgy
capitalisation rules that this is a getter for the property "LEyesight" and
NOT the property "lEyesight".
<whinge>
IMHO it should consider it a getter for both, but alas, it does not, thus
leaving you pretty stuffed when you want the second letter of the property
capitalised but not the first. (B!@@#y nuisance that. I had one form with 60
fields named like that and had the change the lot.)
</whinge>
Now if you really truly need to use that property name there is a way (I
havent done it yet myself though so cant give too many details). Have a look
at the BeanInfo interface in the J2SE JavaDocs and the beans spec at:
http://java.sun.com/products/javabeans/docs/spec.html
(You will probably find renaming the field a lot less trouble though!)
-----Original Message-----
From: Gene Ge [mailto:gene_ge80@hotmail.com]
Sent: Tuesday, August 27, 2002 18:00
To: struts-user@jakarta.apache.org
Subject: problem with PropertyUtils.getProperty()
hello everyone;
I meet a problem please help me.
I have a action which forwards to a jsp file, some scripts of jsp are:
<html:text property="stature" size="16" maxlength="16"/>
...<html:text property="avoirdupois" size="16" maxlength="16"/>
...<html:text property="lEyesight" size="16" maxlength="16"/>
...<html:text property="rEyesight" size="16" maxlength="16"/>
...
when invoked, I got a Exception:
javax.servlet.jsp.JspException: No getter method for property lEyesight of
bean
org.apache.struts.taglib.html.BEAN
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:716)
at
org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.ja
va:192)
at
org.apache.jsp.EditHealthInfo$jsp._jspService(EditHealthInfo$jsp.java
:413)
so I trid to invoked the formbean's "getLEyesight" method, it gave the right
out
put which proved that "lEyesight" property's getter really exist.
then I delete the
<html:text property="lEyesight" size="16" maxlength="16"/>
<html:text property="rEyesight" size="16" maxlength="16"/>
from my jsp script(both of lEyesight and rEyesight will cause the problem)
and t
his time it work well.
I was confused so I check the source code of struts and found the problem
existe
d in the
org.apache.commons.beanutils.PropertyUtils.getProperty(bean, property)
so I added this operation in my action like this:
healform=new HealthInfoForm(gm.getHealthInfoData());//get a form
System.out.println("invoke in action:"+healform.getLEyesight());//invoke
dir
ectly
try{
String
leye=(String)org.apache.commons.beanutils.PropertyUtils.getPr
operty(healform,"lEyesight");
System.out.println("leyesight="+leye);//try struts way to get
proper
ty
}
catch(Exception e){
System.out.println("exception when do getProperty:"+e);
e.printStackTrace();
}
session.setAttribute(mapping.getAttribute(),healform);
the result is:
15:27:31,115 INFO [STDOUT] invoke in action:5.0
15:27:31,165 INFO [STDOUT] exception when do
getProperty:java.lang.NoSuchMethod
Exception: Unknown property 'lEyesight'
15:27:31,095 ERROR [STDERR] java.lang.NoSuchMethodException: Unknown
property 'l
Eyesight'
15:27:31,095 ERROR [STDERR] at
org.apache.commons.beanutils.PropertyUtils.ge
tSimpleProperty(PropertyUtils.java:1151)
15:27:31,095 ERROR [STDERR] at
org.apache.commons.beanutils.PropertyUtils.ge
tNestedProperty(PropertyUtils.java:751)
15:27:31,095 ERROR [STDERR] at
org.apache.commons.beanutils.PropertyUtils.ge
tProperty(PropertyUtils.java:780)
15:27:31,095 ERROR [STDERR] at
com.bit.job.actions.EditHealthInfoAction.exec
ute(EditHealthInfoAction.java:58)
so it can be invoked directly but can not through PropertyUtils?
I tried to find something in the PropertyUtils' source code, but for my
limit kn
owledges I couldn't find anything.
thanks a lot.
best regards!
Gene
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
--
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: problem with PropertyUtils.getProperty()
Posted by Emmanuel Boudrant <b7...@yahoo.fr>.
Hi,
bean-utils use the JavaBean specification, and a property named xXxxx isn't conventional.
An javabean attribute must have a least two letters in lower case.
xXxx > not valid
xxXxx > valid
see documentation : http://java.sun.com/products/javabeans/docs/
-Emmanuel
--- Gene Ge <ge...@hotmail.com> a écrit : > hello everyone;
> I meet a problem please help me.
> I have a action which forwards to a jsp file, some scripts of jsp are:
>
> <html:text property="stature" size="16" maxlength="16"/>
> ...<html:text property="avoirdupois" size="16" maxlength="16"/>
> ...<html:text property="lEyesight" size="16" maxlength="16"/>
> ...<html:text property="rEyesight" size="16" maxlength="16"/>
> ...
>
> when invoked, I got a Exception:
> javax.servlet.jsp.JspException: No getter method for property lEyesight of
> bean
> org.apache.struts.taglib.html.BEAN
> at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:716)
> at
> org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.ja
> va:192)
> at
> org.apache.jsp.EditHealthInfo$jsp._jspService(EditHealthInfo$jsp.java
> :413)
>
> so I trid to invoked the formbean's "getLEyesight" method, it gave the right
> out
> put which proved that "lEyesight" property's getter really exist.
>
> then I delete the
> <html:text property="lEyesight" size="16" maxlength="16"/>
> <html:text property="rEyesight" size="16" maxlength="16"/>
> from my jsp script(both of lEyesight and rEyesight will cause the problem)
> and t
> his time it work well.
>
> I was confused so I check the source code of struts and found the problem
> existe
> d in the
> org.apache.commons.beanutils.PropertyUtils.getProperty(bean, property)
> so I added this operation in my action like this:
>
> healform=new HealthInfoForm(gm.getHealthInfoData());//get a form
> System.out.println("invoke in action:"+healform.getLEyesight());//invoke
> dir
> ectly
> try{
> String
> leye=(String)org.apache.commons.beanutils.PropertyUtils.getPr
> operty(healform,"lEyesight");
> System.out.println("leyesight="+leye);//try struts way to get
> proper
> ty
> }
> catch(Exception e){
> System.out.println("exception when do getProperty:"+e);
> e.printStackTrace();
> }
> session.setAttribute(mapping.getAttribute(),healform);
>
> the result is:
> 15:27:31,115 INFO [STDOUT] invoke in action:5.0
> 15:27:31,165 INFO [STDOUT] exception when do
> getProperty:java.lang.NoSuchMethod
> Exception: Unknown property 'lEyesight'
> 15:27:31,095 ERROR [STDERR] java.lang.NoSuchMethodException: Unknown
> property 'l
> Eyesight'
> 15:27:31,095 ERROR [STDERR] at
> org.apache.commons.beanutils.PropertyUtils.ge
> tSimpleProperty(PropertyUtils.java:1151)
> 15:27:31,095 ERROR [STDERR] at
> org.apache.commons.beanutils.PropertyUtils.ge
> tNestedProperty(PropertyUtils.java:751)
> 15:27:31,095 ERROR [STDERR] at
> org.apache.commons.beanutils.PropertyUtils.ge
> tProperty(PropertyUtils.java:780)
> 15:27:31,095 ERROR [STDERR] at
> com.bit.job.actions.EditHealthInfoAction.exec
> ute(EditHealthInfoAction.java:58)
>
> so it can be invoked directly but can not through PropertyUtils?
> I tried to find something in the PropertyUtils' source code, but for my
> limit kn
> owledges I couldn't find anything.
>
> thanks a lot.
>
> best regards!
> Gene
>
>
>
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>