commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raible, Matt" <>
Subject [beanutils] BeanUtils.copyProperties: POJOs -> Forms Automagicall y
Date Fri, 17 Jan 2003 16:51:09 GMT

> The JavaBeans spec defines indexed getters and putters only for things
> that pass and return arrays, not Lists.  Therefore, this isn't going to
> get recognized as a property by the standard introspector.
> Commons-beanutils tries to extend the model so that you can use List-based
> properties like this, but looks like it doesn't cover this particular use
> case.  Could you please post a bug with a small example that illustrates
> it?


Another question on this same topic.  How would I create a custom converter
that changes my POJOs into ActionForms?  Currently, I do this the
(seemingly) hard way:

// get HSCRFMaster (with children) from persistence layer
HSCRFMasterDAO formDAO = factory.createHSCRFMasterDAO();
HSCRFMaster h = formDAO.getHSCRFMaster(Long.valueOf(form.getId()));

// create form for the UI and populate
HSCRFMasterForm hscrfForm = new HSCRFMasterForm();
BeanUtils.copyProperties(hscrfForm, h);

// loop through the Mux List and use forms instead of POJOs
ArrayList muxList = hscrfForm.getMuxs();
for (int i = 0; i < muxList.size(); i++) {
	HSCRFMux m = (HSCRFMux) muxList.get(i);

	// create form for the UI and populate
	HSCRFMuxForm muxForm = new HSCRFMuxForm();
	BeanUtils.copyProperties(muxForm, m);
	muxList.set(i, muxForm);

I'd love to have the copyProperties do the work of creating forms for the
children.  All my ActionForms are generated using XDoclet, so they have the
same name as the POJO + the word "Form".



View raw message