struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kothari, Kailash" <Kailash_Koth...@intuit.com>
Subject RE: Inheritance within form beans
Date Tue, 02 Oct 2007 16:40:44 GMT
Thaks Rick.

This will give me an instance of the parent bean OR the child bean.

What I need is a child bean pre populated with data from the parent
bean.

Note that we cannot get an instance of the parent bean and downcast it
to an instance of a child bean like -
child bean = ((child bean)(instance of parent bean));

Since java does not allow such downcasting.

Would appreciate anything to help me move along !

-----Original Message-----
From: Rick Reumann [mailto:rick.reumann@gmail.com] 
Sent: Monday, October 01, 2007 5:57 PM
To: Struts Users Mailing List
Subject: Re: Inheritance within form beans

On 10/1/07, Kothari, Kailash <Kailash_Kothari@intuit.com> wrote:
 > What I also need is that, when a child form bean is instantiated by
> Struts, I want Struts to check if there is an instance of the parent 
> form bean in the session and if so, pre populate that data from the 
> parent to the child form bean.

Assuming Struts 1.x...

I can't recall the exact syntax of how the forms are stored in the
session but I know it invovles the  ActionMapping name in the
StrutsConfig, so you could try:

(YourForm)session.getAttribute(yourActionMappingName);

(remember you could have different session scoped instances of the same
type of ActionForm in the session - the key is the action mapping name
they are tied to.)


-----Original Message-----
From: Kothari, Kailash [mailto:Kailash_Kothari@intuit.com] 
Sent: Monday, October 01, 2007 5:31 PM
To: user@struts.apache.org
Subject: Inheritance within form beans

Hello,

I have an interesting Struts design requirement and Im a little lost,
would really appreciate help !

I have multiple form beans in my application and a lot of them share
data.

Instead of duplicating the common attributes in each form bean, I am
opting for an more elegant approach, i.e. encapsulating the common data
in a parent form bean and then building child form beans that extend the
form.

So that's fine.

What I also need is that, when a child form bean is instantiated by
Struts, I want Struts to check if there is an instance of the parent
form bean in the session and if so, pre populate that data from the
parent to the child form bean.

Of course I could copy that data manually, but the parent form bean is a
legacy class and has grown beyond proportion - hundreds of attributes
and contained objects.

Thanks !
Kailash.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message