You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Erik Hatcher <ja...@ehatchersolutions.com> on 2002/09/13 16:18:05 UTC

Bean -> Map with nested properties

I have a need to convert a Struts ActionForm bean back into a Map, 
complete with dotted syntax for nested fields.  For example, I have this:

	ContactInfoForm
		private String lastName;
		private AddressForm homeAddress;

	AddressForm
		private String addressLine1;

(getters/setters for each)

I want to construct and populate ContactInfoForm down into its nested 
AddressForm.  And then turn around and get a Map that is keyed this way:

	lastName
	homeAddress.addressLine1

Can I get there from here using BeanUtils or any other slick Commons 
facilities?  If so, how?  BeanUtils.describe gave me back the flat 
picture of the form, but I need the nested.

Use case: I'm writing Cactus test cases for Struts, using 
strutstestcase.sourceforge.net.  While that project takes care of lots 
of things, it still requires you to know all the request parameters and 
manually add each one.  I'd like to make that a bit cleaner for our 
developers so they can simply create a form bean, call bean setters, 
then behind the scenes it gets turned into request parameters to submit.

Thanks,
	Erik


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>