You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Fernando Jimenez <fe...@db.com> on 2003/04/08 13:51:00 UTC

How to get a reference to an ActionForm in a JSP

Hi

I have a little bit of a dilema here, and I hope someone can help me out.

Here is what I'm trying to do:

I'm trying to display a set of values in a table, where the user will be able to edit some fields in each row. So in each row, there is static data, as well as some data he/she will be able to modify.

I thought I would put all the data, static and user modifiable, in an ActionForm, to keep it all in one place.

Now, I'm not too sure of what the best way to go on about this would be. I could either use a Map-backed ActionForm, and put all the data in one single Map. Then I would have to, somehow, get a list of something to index this map. So if I had a list of carmodels, and characteristics, I could have a list of carmodels, and then access the map with keys such as carmodel+"enginesize", carmodel+"colour", and so on

Or I could store each characteristic on a different map, and then index each map by carmodel.

Now, the questions are:

- How and where would I store the list of "carmodels" in this example? I could store it in the session, but would it be possible to store it in the ActionForm?
- If stored in the ActionForm, how could I get a reference to the action form so that I could get the list in the JSP to cycle through it and build the table?

If I could get a reference to the ActionForm in the JSP, I could then access my static data easily to display it in the table. At the moment, I have to put my static data in the session (such as the list of keys (carmodels in the example)), and retrieve the dynamic data using struts tag libraries such as <html:text property="engine(carmodel">.  But I think this is a bit messy.

Any help, hints, or ideas would be much appreciated

Oh, sorry if my question(s) are a bit obvious. I'm just starting with struts

Thanks

FJ


--

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.



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


Re: How to get a reference to an ActionForm in a JSP

Posted by Navjot Singh <na...@net4india.net>.
hi,

Naturally, your jsp must have been connected to your ActionForm somehow. All
the variables of ActionForm should be automatically displayed to you.

If NOT
If you wish to have ActionForm object in your jsp, just write one line in
your Action class
request.setAtribute("carmodelform", carModelForm);
oops, not a nice idea ;-)

navjot

----- Original Message -----
From: "Fernando Jimenez" <fe...@db.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, April 08, 2003 5:21 PM
Subject: How to get a reference to an ActionForm in a JSP


| Hi
|
| I have a little bit of a dilema here, and I hope someone can help me out.
|
| Here is what I'm trying to do:
|
| I'm trying to display a set of values in a table, where the user will be
able to edit some fields in each row. So in each row, there is static data,
as well as some data he/she will be able to modify.
|
| I thought I would put all the data, static and user modifiable, in an
ActionForm, to keep it all in one place.
|
| Now, I'm not too sure of what the best way to go on about this would be. I
could either use a Map-backed ActionForm, and put all the data in one single
Map. Then I would have to, somehow, get a list of something to index this
map. So if I had a list of carmodels, and characteristics, I could have a
list of carmodels, and then access the map with keys such as
carmodel+"enginesize", carmodel+"colour", and so on
|
| Or I could store each characteristic on a different map, and then index
each map by carmodel.
|
| Now, the questions are:
|
| - How and where would I store the list of "carmodels" in this example? I
could store it in the session, but would it be possible to store it in the
ActionForm?
| - If stored in the ActionForm, how could I get a reference to the action
form so that I could get the list in the JSP to cycle through it and build
the table?
|
| If I could get a reference to the ActionForm in the JSP, I could then
access my static data easily to display it in the table. At the moment, I
have to put my static data in the session (such as the list of keys
(carmodels in the example)), and retrieve the dynamic data using struts tag
libraries such as <html:text property="engine(carmodel">.  But I think this
is a bit messy.
|
| Any help, hints, or ideas would be much appreciated
|
| Oh, sorry if my question(s) are a bit obvious. I'm just starting with
struts
|
| Thanks
|
| FJ
|
|
| --
|
| This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
|
|
|
| ---------------------------------------------------------------------
| 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