struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Affan Qureshi" <>
Subject Re: Bean Utils - Help needed
Date Tue, 22 Oct 2002 08:09:23 GMT

The org.apache.commons.beanutils package contains several classes that are
used throughout the Struts framework. From the standpoint of the Struts
framework, the two most important are the BeanUtils and PropertyUtils

As you might have guessed, the BeanUtils class is used with JavaBeans. The
Struts components primarily use just three of the methods in the BeanUtils

·         populate()

·         getProperty()

·         getArrayProperty()

The populate() method is used to fill a JavaBean with data, using a map of
key/value pairs. The method signature for the populate() method is shown

public static void populate( Object bean, Map properties )

  throws IllegalAccessException, InvocationTargetException;

The getProperty() method returns a String representation of the property
stored in the variable with the name that matches the value of the name

public static String getProperty( Object bean, String name )

  throws IllegalAccessException, InvocationTargetException,

Regardless of the type of property that the name argument references, it
will be converted and returned as a String.

The getArrayProperty() method returns the value of the specified array
property of the specified bean, as a String array. Here is the method
signature for the getArrayProperty() method.

public static [] getArrayProperty(Object bean, String name)

  throws IllegalAccessException, InvocationTargetException,

Although the Java language provides reflection and introspection as part of
its core API's, the BeanUtils class provides convenience wrappers around
these API's.

The other class that is used by the Struts framework is that PropertyUtils
class. However, only one method is currently used, the getProperty() method.

public static Object getProperty(Object bean, String name)

  throws IllegalAccessException, InvocationTargetException,

The getProperty() method in the PropertyUtils class returns the value of the
specified property, without attempting to convert the type.  Much of the
code that is in the PropertyUtils class was originally implemented in the
BeanUtils class. It was moved to its own class due to the size that
BeanUtils was becoming.

----- Original Message -----
From: "Podhigai Thendral" <>
To: <>
Sent: Tuesday, October 22, 2002 1:04 AM
Subject: Bean Utils - Help needed

> Hi all,
> I see a commons-beanutils.jar file that comes with struts. I would
> like to know the functionalities offered by this package. I read
> somewhere that this is the one that helps in auto population of
> the form beans. Is it right ? Please help.
> Thanks in advance.
> -Thendral
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message