You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by YOUSFI <yo...@stef-tfe.fr> on 2004/04/13 14:53:41 UTC

Problem with BeanUtils

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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org