Rafael,
Look at your config file. Look at your form bean declaration. Notice that
it has a name, an implementation class, and (possibly) defines the fields in
the form.
Look at your action declaration. The "name" attribute for an action that
has an associated form will match one of the names you specified in
declaring your form beans. Now, look at the "scope" attribute on that same
action. This is the scope that struts is going to look for that form in -
and create it if it doesn't already exist.
Struts is going to pass-in your form as the "form" (ActionForm) parameter of
execute. Sure, you can grab it out of the request (or session) by yourself,
but that seems kind of silly, since you're *guaranteed* that Struts will
initialize the form for you (provided you declared that the action uses the
form). If you really do want to take this upon yourself, use the mapping
parameter. The mapping parameter will indicate both the name the form is
stored in, as well as the scope it may be found. In fact, this is what
Struts uses to retrieve the form for you.
There is one circumstance whereby you might want to get the form yourself:
You didn't (for whatever reason) tell Struts about it so that it could
handle this on your behalf. Ordinarily, this shouldn't happen, but you
could possibly have some special use-case where it's legitimate, I suppose
(I haven't seen one yet, but that doesn't mean it doesn't exist).
Is that clear as mud?
I'm not sure what you're asking when you say, "How can I store the data
before the user click on the link
button?". Maybe you're trying to set some hidden fields or something? On
occassion, I need to do something to make the GUI behave correctly (aka
adding "glitz" - that's a technical term), and I resort to JavaScript. If
that doesn't help, try elaborating more on what you mean. Just for
clarification, you don't have access ot the "session" on the client side
(since session data is stored on the server), so you can't set values in the
session before the form submits.
HTH,
Eddie Bush
----- Original Message -----
From: "Rafael Taboada" <[EMAIL PROTECTED]>
To: "Struts List" <user@struts.apache.org>
Sent: Monday, May 30, 2005 1:36 PM
Subject: I'm confused
Hi folks. I'm confused about using ActinForms.. Please can u help to find
the light?
When I have form in a jsp and when i click the submit button... The
actionform associated with the actionmapping is created in the session
context? I mean, is the actionform created as an attribute in the session
user?
Because I have a sample code downloaded from
http://courses.coreservlets.com/Course-Materials/struts.html, Prepopulating
and Redisplaying Input Forms section, and It calls an actionform attribute
with:
ContactFormBean contactFormBean =
(ContactFormBean)request.getAttribute("contactFormBean");
Another problem is that I have my form but with other links to add more
data to my form. How can I store the data before the user click on the link
button? How can I sotre the data in my session attribute?
thanks for ur help
--
Rafael Taboada
Cell : 511-97753290
"No creo en el destino pues no me gusta tener la idea de controlar mi vida"
---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0522-0, 05/30/2005
Tested on: 5/30/2005 5:26:13 PM
avast! - copyright (c) 2000-2004 ALWIL Software.
http://www.avast.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]