commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Heath Chiavettone" <>
Subject BeanUtils.populate() question
Date Wed, 10 Apr 2002 01:34:52 GMT
I know that this package is mostly used by Struts but it is designed to be
used generically.  We are in the process of evolving to Struts, but it will
take some time.  So here is the scenario I'm thinking of using this in.


In our (Model 1) world, we have designed our JSPs to be mated to a JavaBean
which is used to process all of the data for the form.  We are using a
custom tag to "initialize" these beans on in the JSP and then use the
<jsp:setProperty name="*"/> mechanism in the JSP to "bind" the data to the
bean.  Recently, we have begun using a (Servlet 2.3) filter, to
pre-processed the request and convert the String and String[] into the
appropriate object types such Integer, BigDecimal, Long, and several other
application-specific "primitive" types (using a custom mechanism) and stores
them in the request as attributes (keyed to the parameter name).  As a
result, I can now create a Map that is keyed to the property name, but will
contain the not only the basic String or String[] values for all "real"
string properties, but also these other object types.  Rather than using the
setProperty * mechanism, I would like to modify the custom tag to use the
BeanUtils package to improve our "binding" mechanism.  In looking at the
Javadoc (see below) for the populate method, I'm not to sure if what I want
to do will work.


I was wondering if the BeansUtil.populate() method could be used in the
following manner:



bean - JavaBean whose properties are being populated 

properties - Map keyed by property name, with the corresponding (String or
String[]) value(s) to be set


So I guess I have couple of questions:


1.	Can I use populate to accomplish my goal of binding the Map of the
various property "Objects" to the appropriate bean properties?
2.	If not, then will the PropertyUtils.set*() class of methods work?
3.	If so, will I gain any of the Introspection performance gains that I
believe BeanUtils.populate gives me?





  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message