You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Duncan Harris <du...@sapio.co.uk> on 2002/01/18 16:37:00 UTC

Form Beans not derived from ActionForm

I am using struts 1.01 and haven't looked at 1.1 code yet, so please
excuse if this has been addressed.

I would like some of my form beans to not have a dependency on struts
so I can use them in other apps that operate on the same back end, but
are not web apps.

I can't see struts couldn't be modified so that this was optionally the case.
Struts could still pass the ActionForm into the perform(), but there might
be a getBean() method on it to handle this case (obviously your perform code
would know which type of bean it was expecting). Also getBean() could
return 'this' if the bean was derived from ActionForm.

The struts code could detect whether the bean class was derived from 
ActionForm and do slightly different things in each case. For example
it could call reset() via reflection on the bean when the bean class was
not derived rom ActionForm.

Has anyone else considered this requirement for a bean which is not
dependent on struts to be used as a form bean?

Duncan Harris
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hartford, Cheshire, U.K., Tel: 07968 060418

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


Re: Form Beans not derived from ActionForm

Posted by Ted Husted <hu...@apache.org>.
Very few pre-existing beans would meet the design requirements of
ActionForm beans. 

http://jguru.com/faq/view.jsp?EID=471954

As mentioned, you can use the dotted syntax to nest other beans, but its
usually easier to transfer the data in the Action after the validation
is said and done.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/


Duncan Harris wrote:
> 
> I am using struts 1.01 and haven't looked at 1.1 code yet, so please
> excuse if this has been addressed.
> 
> I would like some of my form beans to not have a dependency on struts
> so I can use them in other apps that operate on the same back end, but
> are not web apps.
> 
> I can't see struts couldn't be modified so that this was optionally the case.
> Struts could still pass the ActionForm into the perform(), but there might
> be a getBean() method on it to handle this case (obviously your perform code
> would know which type of bean it was expecting). Also getBean() could
> return 'this' if the bean was derived from ActionForm.
> 
> The struts code could detect whether the bean class was derived from
> ActionForm and do slightly different things in each case. For example
> it could call reset() via reflection on the bean when the bean class was
> not derived rom ActionForm.
> 
> Has anyone else considered this requirement for a bean which is not
> dependent on struts to be used as a form bean?
> 
> Duncan Harris
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Hartford, Cheshire, U.K., Tel: 07968 060418
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

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