|
From: Erwin V. <erw...@er...> - 2005-04-07 14:48:54
|
> Next to the "formObjectClass" property I think it would the useful to
> add a "formObjectBean" string property which could be any bean ref id
> in the bean factory (must be prototypes). This way one could control
> the creation of the beans through Spring. You could for example
> already fill in default values which could facilitate the re-use of
> domain classes as form objects.
Mmm, interesting idea, but I'm not sure we should add this (e.g. why doesn't
the
BaseCommandController has this feature?). Anyway, it would be trivial to do
this
in a FormAction subclass:
public class MyFormAction extends FormAction {
private MyBean myBean;
public void setMyBean(MyBean myBean) {
this.myBean = myBean;
}
protected Object loadRequiredFormObject(RequestContext context) throws
FormObjectRetrievalFailureException, IllegalStateException {
return myBean;
}
}
> Another remark regarding usage of domain classes as form objects is
> about jumping over properties in the form object. Say my form object
> is a Manager instance which has a "person" property. Person has a
> "name" property. Is it possible to add a "person.name" HTTP parameter
> that would set the "name" property on the "person" property?
This is possible with the Spring DataBinder. Ofcourse the "getPerson()"
method
on the Manager class should not return null in that case.
Erwin
|