You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Meka Struts <Me...@hotmail.com> on 2003/07/24 21:58:21 UTC

Question About Passing Values from Action Class

Hi,

I have an Action Class which has 2 methods

* an execute method that forwards using ActionMapping
* a protected method getXXX(), which return an ArrayList of objects to execute method.

My question is, how would i pass the ArrayList to the view page (jsp) so that it can extract data from ArrayList and display it.

I am actually going though an example and it seems to have missed that part. I cant get to understand how will the ArrayList object be passed ?

Thank You

Meka Toka

RE: Question About Passing Values from Action Class

Posted by Mike Jasnowski <mj...@bea.com>.
If you use the Struts method of using a FormBean, placing the bean into the
session is handled for you.  You obviously still have to populate the
formbean with your data.  You can also utilize DynaActionForms (declarative)
or code your own formBean that extends ActionForm.

When you are forwarded to your JSP, the various struts/JSTL tags will look
for the formBean named in the STruts ActionClass config (name) attribute,
which maps to a "<formBean>" definition.  You can then operate on it via the
tag itself or expose it (depending on the tag you use) via a scripting
variable and use other tags on the page to process it.

Generally most of the struts tags have a "name" attribute where you identify
the bean attribute name, this can also of course be the "id" you may have
exposed from another tag.

-----Original Message-----
From: Meka Struts [mailto:MekaStruts@hotmail.com]
Sent: Thursday, July 24, 2003 4:24 PM
To: Struts Users Mailing List
Subject: Re: Question About Passing Values from Action Class


Hi Mike,

Got your point. Thank You

In that case, how would the view classes be helpful. Because some people
will write View classes (plain java files with get/set - java beans )

Can i set the view class also in the session so that the View JSP can access
it and show the data ?

This situation will be arising when i have a data layer which returns me a
Bussiness Object. So i fill the data from bussiness object to view class and
then pass on to view jsp.

Please correct me if any part of above statement doesnt make sense.

Thank You

Meka Toka

PS: I have read and read 2 books, i am just clearing my doubts.


----- Original Message -----
From: "Mike Jasnowski" <mj...@bea.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, July 24, 2003 4:10 PM
Subject: RE: Question About Passing Values from Action Class


> Generally you would stuff this ArrayList in a formbean accessible via a
> public getter, or you could I suppose put it in the session yourself as a
> scoped attribute. Then in the JSP you access it by that attribute name.
>
> -----Original Message-----
> From: Meka Struts [mailto:MekaStruts@hotmail.com]
> Sent: Thursday, July 24, 2003 3:58 PM
> To: struts-user@jakarta.apache.org
> Subject: Question About Passing Values from Action Class
>
>
> Hi,
>
> I have an Action Class which has 2 methods
>
> * an execute method that forwards using ActionMapping
> * a protected method getXXX(), which return an ArrayList of objects to
> execute method.
>
> My question is, how would i pass the ArrayList to the view page (jsp) so
> that it can extract data from ArrayList and display it.
>
> I am actually going though an example and it seems to have missed that
part.
> I cant get to understand how will the ArrayList object be passed ?
>
> Thank You
>
> Meka Toka
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

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



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


Re: Question About Passing Values from Action Class

Posted by Meka Struts <Me...@hotmail.com>.
Hi Mike,

Got your point. Thank You

In that case, how would the view classes be helpful. Because some people
will write View classes (plain java files with get/set - java beans )

Can i set the view class also in the session so that the View JSP can access
it and show the data ?

This situation will be arising when i have a data layer which returns me a
Bussiness Object. So i fill the data from bussiness object to view class and
then pass on to view jsp.

Please correct me if any part of above statement doesnt make sense.

Thank You

Meka Toka

PS: I have read and read 2 books, i am just clearing my doubts.


----- Original Message -----
From: "Mike Jasnowski" <mj...@bea.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, July 24, 2003 4:10 PM
Subject: RE: Question About Passing Values from Action Class


> Generally you would stuff this ArrayList in a formbean accessible via a
> public getter, or you could I suppose put it in the session yourself as a
> scoped attribute. Then in the JSP you access it by that attribute name.
>
> -----Original Message-----
> From: Meka Struts [mailto:MekaStruts@hotmail.com]
> Sent: Thursday, July 24, 2003 3:58 PM
> To: struts-user@jakarta.apache.org
> Subject: Question About Passing Values from Action Class
>
>
> Hi,
>
> I have an Action Class which has 2 methods
>
> * an execute method that forwards using ActionMapping
> * a protected method getXXX(), which return an ArrayList of objects to
> execute method.
>
> My question is, how would i pass the ArrayList to the view page (jsp) so
> that it can extract data from ArrayList and display it.
>
> I am actually going though an example and it seems to have missed that
part.
> I cant get to understand how will the ArrayList object be passed ?
>
> Thank You
>
> Meka Toka
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

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


RE: Question About Passing Values from Action Class

Posted by Mike Jasnowski <mj...@bea.com>.
Generally you would stuff this ArrayList in a formbean accessible via a
public getter, or you could I suppose put it in the session yourself as a
scoped attribute. Then in the JSP you access it by that attribute name.

-----Original Message-----
From: Meka Struts [mailto:MekaStruts@hotmail.com]
Sent: Thursday, July 24, 2003 3:58 PM
To: struts-user@jakarta.apache.org
Subject: Question About Passing Values from Action Class


Hi,

I have an Action Class which has 2 methods

* an execute method that forwards using ActionMapping
* a protected method getXXX(), which return an ArrayList of objects to
execute method.

My question is, how would i pass the ArrayList to the view page (jsp) so
that it can extract data from ArrayList and display it.

I am actually going though an example and it seems to have missed that part.
I cant get to understand how will the ArrayList object be passed ?

Thank You

Meka Toka


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