RE: RE: Populating form in the action

2001-12-06 Thread Knee, Jeff

I've noticed that if the ActionForm's validate method returns ActionErrors
then the Action's perform() won't get called, and the user gets sent to the
JSP automagically.

(You can get around this... I've been trying to decide the best way... )

Seems like a great FAQ question since I've seen various flavors of this
question repeated on the list.  The kickstart FAQ is nice and "Ted's
Catalog" (http://husted.com/about/scaffolding/catalog.htm) is also good...
but I wish there was a better FAQ around... I don't feel I know/understand
enough yet to start one.  Is there one in progress?

+= Jeff Knee

> -Original Message-
> From: Joey Gibson [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 06, 2001 8:37 AM
> To: [EMAIL PROTECTED]
> Subject: Re: RE: Populating form in the action
> 
> 
> > The form passed in is a null because that Action is
> > called the first time I type in the URL (.do), not
> > after a form has been submited.
> > 
> > In other words, I would like to "pre-populate" the
> > form before displaying it.
> 
> If you have associated the action with a form in your 
> struts-config.xml, then any time your perform() method is 
> executed, there should be a form instance present. I use this 
> on my site. I do a GET on the action to, for example, edit my 
> account record. I fetch the user record, prepopulate the 
> form, and then forward to the jsp. Here's a code snippet:
> 
> public void perform(..., ActionForm form, ...)
> {
>  UserForm userForm = (UserForm) form;
> 
>  if (request.getMethod().equalsIgnoreCase("get"))
>  {
>userForm.setName(...)
>// ...
>  }
> }
> 
> --
> Sent via jApache.org
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: RE: Populating form in the action

2001-12-06 Thread Joey Gibson

> The form passed in is a null because that Action is
> called the first time I type in the URL (.do), not
> after a form has been submited.
> 
> In other words, I would like to "pre-populate" the
> form before displaying it.

If you have associated the action with a form in your struts-config.xml, then any time 
your perform() method is executed, there should be a form instance present. I use this 
on my site. I do a GET on the action to, for example, edit my account record. I fetch 
the user record, prepopulate the form, and then forward to the jsp. Here's a code 
snippet:

public void perform(..., ActionForm form, ...)
{
 UserForm userForm = (UserForm) form;

 if (request.getMethod().equalsIgnoreCase("get"))
 {
   userForm.setName(...)
   // ...
 }
}

--
Sent via jApache.org

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: RE: Populating form in the action

2001-12-05 Thread John Ng

The form passed in is a null because that Action is
called the first time I type in the URL (.do), not
after a form has been submited.

In other words, I would like to "pre-populate" the
form before displaying it.

Thanks
John



--- Joey Gibson <[EMAIL PROTECTED]> wrote:
> > 
> > For instance, I create a ActionForm in the perform
> > method of the Action class, and then forward the
> > control to a jsp page.  How does the JSP page know
> > that the form that it gets is the form that just
> get
> > populated in the Action before?  
> 
> Don't create an instance of the form, use the one
> that is passed in to your perform(...) method. You
> will need to cast it, of course.
> 
> Joey
> 
> --
> Sent via jApache.org
> 
> --
> To unsubscribe, e-mail:  
> 
> For additional commands, e-mail:
> 
> 


__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: RE: Populating form in the action

2001-12-05 Thread Joey Gibson

> 
> For instance, I create a ActionForm in the perform
> method of the Action class, and then forward the
> control to a jsp page.  How does the JSP page know
> that the form that it gets is the form that just get
> populated in the Action before?  

Don't create an instance of the form, use the one that is passed in to your 
perform(...) method. You will need to cast it, of course.

Joey

--
Sent via jApache.org

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Populating form in the action

2001-12-05 Thread Siggelkow, Bill

It knows because you access the form via the  tag.

-Original Message-
From: John Ng [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 05, 2001 2:25 PM
To: Struts Users Mailing List
Subject: Populating form in the action 


Hi, I have some questions about how to populate the
form in the action.

For instance, I create a ActionForm in the perform
method of the Action class, and then forward the
control to a jsp page.  How does the JSP page know
that the form that it gets is the form that just get
populated in the Action before?  (Provided the form is
the request scope).

Thanks
John


__
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com

--
To unsubscribe, e-mail:

For additional commands, e-mail:


--
To unsubscribe, e-mail:   
For additional commands, e-mail: