I found the problem. The Object passed to getLibelle was in fact a String. What happen is the following : - before passing the object (TypAbonne ) to getLibelle I put it in a Collection in a ActionForm property, - then I read this collection in the following way :
Object options[] = BeanUtils.getArrayProperty(form, liste); The options array is filled with a list of String(s) (my TypAbonne converted to String :[EMAIL PROTECTED]). - Then I pass the options array element to the getLibelle method. Thanks to all of you for help ! -----Message d'origine----- De : news [mailto:[EMAIL PROTECTED] la part de Bill Siggelkow Envoye : mardi 13 avril 2004 14:05 A : [EMAIL PROTECTED] Objet : Re: Problem with BeanUtils First of all, I assume that you are calling the getProperty method of BeanUtils -- Are you sure that the object you are passing is an instance of your class (TypAbonne) -- from what you indicated it sounds like it is actually a String -- java.lang.String has two "getter" methods -- getClass() and getBytes(). YOUSFI wrote: > Hi all, > I'm trying to use BeanUtils (I have the same problem with PropertyUtils) to > read dynamically a bean property. But it does not work. I think I'm missing > some thing very impportant. > > I have a bean wuith some properties(see below TypAbonne.java). > When I pass a bean instance of this classand the string "lecode" to the > following methode : > > String getLibelle(Object obj,String prop) > { > return BeanUtils(obj,prop); > } > > I receive a NoSuchMethodException: > When I try to debug the code I see that PropertyDescriptor array associated > with my class TypAbonne contains only two descriptors : one for the property > "class" and the other for the property "bytes" and there are no others > descriptor for the properties "lecode" and "lelibelle". > > What's wrong in the code above ? > May be my class TypAbonne should satisfy some others conditions ? > Is it necessary to create a typAbonneBeanInfo and override the mthod > getPropertyDescriptors ? > Thank you a lot for your help. > > The exception received ---------------------------------------------------- > > java.lang.NoSuchMethodException: Unknown property 'lecode' > at > org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.j > ava:1175) > at > org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.j > ava:772) > at > org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:80 > 1) > at > fr.tfe.utils.tags.TFESelectTag.getLibelleSelectionne(TFESelectTag.java:122) > at fr.tfe.utils.tags.TFESelectTag.doStartTag(TFESelectTag.java:72) > > TypAbonne.java ------------------------------------------------------------- > - > public class TypeAbonne implements Serializable { > > private String lecode = null; > > private String lelibelle = null; > > /** > * > */ > public TypeAbonne() { > } > > /** > * @return > */ > public String getLecode() { > return lecode; > } > > /** > * @return > */ > public String getLelibelle() { > return lelibelle; > } > > /** > * @param string > */ > public void setLecode(String string) { > lecode= string; > } > > /** > * @param string > */ > public void setLelibelle(String string) { > lelibelle= string; > } > > } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]