struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Boudrant <b...@yahoo.fr>
Subject Re: problem with PropertyUtils.getProperty()
Date Tue, 27 Aug 2002 10:10:37 GMT
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 <gene_ge80@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:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-help@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:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message