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]



Reply via email to