Brett Porter wrote:
> This can trip you up though - at least once I have added the form element,
> added it to the bean, added it to the form bean, and forgetten to do the
> setter in the action :) The way around that is probably a function in the
> form bean that says "fill my business class" and "fill from a business
> class". Actually, I might put that in my todo list :D
If it helps, here are some methods that do that using reflection. Set
fills this object from another object. Populate fills another object
from this object. I have the luxury of placing these on my base business
class, but, given comparable exceptions, they would work just as well on
an ActionForm. (Hmmm.)
public void set(Object o) throws ModelException {
try {
BeanUtils.populate(this,BeanUtils.describe(o));
} catch (Throwable t) {
throw new ModelPopulateException(t);
}
};
public void populate(Object o) throws ModelException {
try {
BeanUtils.populate(o,BeanUtils.describe(this));
} catch (Throwable t) {
throw new ModelPopulateException(t);
}
}
If there were a mismatch between the property names, one way around that
would be to replace the call to BeanUtils.describe withy a custom
version that generated the appropriate hashmap for the target bean.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>