You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rafael Taboada <ka...@gmail.com> on 2005/05/30 20:36:42 UTC

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"

Re: I'm confused

Posted by Rafael Taboada <ka...@gmail.com>.
I'm trying to cache some data in the session context... If is not possible 
to cache data before the form submit... How can I do this procedure:
 I have a form about a client and his video list.
 At the beginning there are html:text in order to fill his name, his 
telephone number and his address..
 Then, there is the video list. there is a button where the user can click 
it and it goes to another form in order to select a video form a list... 
When the user click on the submit button from this second form, it returns 
to the main form.
 Finally, there is the submit button from the main form... But I realised 
when the user decide to select a video... and when it returns... The 
previous data (name, phone, address) was lost...
 So... How can i do this procedure?.. The button to select the video is a 
link.
 How can I do to cache the name, phone, address before the user click on the 
video link button???...
 I know it's so common but I am a beginner :(
 Please. can u help me?

-- 
Rafael Taboada
Cell : 511-97753290

"No creo en el destino pues no me gusta tener la idea de controlar mi vida"

Re: I'm confused

Posted by Eddie Bush <ea...@swbell.net>.
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" <ka...@gmail.com>
To: "Struts List" <us...@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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org