You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Nicolas De Loof <ni...@cgey.com> on 2002/04/22 16:13:38 UTC

Re: form bean life cycle

[send in copy on Struts-dev list]

In ActionServlet (Struts 1.0.2) you can read that formBean object found in
scope is compared to the form name declared in ActionMapping by testing
class name, not testing it using an "isInstance" or any other reflection
mecanism that could allow using inheritance or abstract FormBeans.

instance = (ActionForm) session.getAttribute(attribute);
...
className = formBean.getType();
...
className.equals(instance.getClass().getName())) {


Can any Struts developper explain if there is a technical reason to this
limitation ?


> Hello all, I a mwondering about this ?
>
> I have a form bean declared abstract and I have subclassed it
> into three concrete form bean classes that I use, this works OK.
>
> Then, I want now, to use an action that does not require to know
> anything about these concretes implementations: I want my
> action to work on the  interface of the abstract form, for this
> I have declared an action-mapping to use a form bean
> of the abstract class and from the session scope, I thought
> that struts won't try to create the form again (actually it
> can't because the form class is abstract), infortunatelly
> the logs of struts told me that struts have tried to create
> it.
>
> My question is why do struts try to recreate the action form
> if it can be found from the session
>
> =============================================================
> -- KeV --
> =============================================================
>
>
>
> --
> 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>


Re: form bean life cycle

Posted by Marcelo Vanzin <va...@rededc.com.br>.
Nicolas De Loof wrote:
> In ActionServlet (Struts 1.0.2) you can read that formBean object found in
> scope is compared to the form name declared in ActionMapping by testing
> class name, not testing it using an "isInstance" or any other reflection
> mecanism that could allow using inheritance or abstract FormBeans.

	It really would be nice to use isInstance() instead of just comparing the 
name. I've had the same issue as Viet, and this solution would be great. 
This way I do not need to have actions declared all over poiting to the 
concrete implementations.

	However, there are issues with this: if the bean has not been previously 
instantiated (from a concrete class implementation, in another action 
mapping), an "InstantiationException" would occur, since the class is 
abstract. What could be done in this case? Currently, Struts fails, but 
that would not be a nice solution in this case...
	
-- 
[]'s
Marcelo Vanzin
Touch Tecnologia
vanza@rededc.com.br
"Life is too short to drink cheap beer"


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