You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kapila, Ranjit" <Ra...@arbitron.com> on 2001/08/01 21:32:05 UTC

processPopulate() call configurable?

Hi,

In the ActionServlet.process() method, the processPopulate() method is
always called. Is there any way to set some request attribute etc so that
the processPopulate call is configurable. 

The underlying problem is that if I prefill my form, all the values are
overwritten by the Request objects current parameter values.

I this something that other people have run into? Any work around?

Thanks,

Ranjit


RE: processPopulate() call configurable?

Posted by Marcel Mare <mj...@webtothemax.com>.
Please see comments below


> If you don't want processPopulate() to be called, just omit the form bean
> from your <action> element.
>
> > The underlying problem is that if I prefill my form, all the values are
> > overwritten by the Request objects current parameter values.
> >
> > I this something that other people have run into? Any work around?
> >
>
> If your case is what I'm thinking it is, you probably want to consider
> using different actions for prepopulating (and then displaying) a form,
> versus accepting (and processing) the form submit.
>
> Consider in the struts-example application what happens when you select
> the "Edit your registration profile" option from the main menu:
>
> * This link goes to the "/editRegistration" action, which
> * Prepopulates the form bean, and

But it does NOT create the bean and RegistrationForm.Reset() is called
because it is listed as a form bean. To circumvent this (to be able to
create the RegistrationForm oneself) it could be omitted as a form bean, but
then you wouldn't be able to get the attribute name (by calling
mapping.getAttribute())

> * Forwards to the "/registration.jsp" page to display it with
>   values from the "database".
> * Then, the form is submitted to the "/saveRegistration" action,
>   which validates the input (returning on any errors) or does
>   the appropriate database action.

The form bean's Reset() would *again* be called possibly undoing all
previous manipulations.
So is the only option to not implement a formbean Reset() method?

Why is this seemingly simple task of prepopulating a form so difficult?

Thanks

Marcel


Re: processPopulate() call configurable?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 1 Aug 2001, Kapila, Ranjit wrote:

> Hi,
> 
> In the ActionServlet.process() method, the processPopulate() method is
> always called. Is there any way to set some request attribute etc so
> that the processPopulate call is configurable.
> 

If you don't want processPopulate() to be called, just omit the form bean
from your <action> element.

> The underlying problem is that if I prefill my form, all the values are
> overwritten by the Request objects current parameter values.
> 
> I this something that other people have run into? Any work around?
> 

If your case is what I'm thinking it is, you probably want to consider
using different actions for prepopulating (and then displaying) a form,
versus accepting (and processing) the form submit.

Consider in the struts-example application what happens when you select
the "Edit your registration profile" option from the main menu:

* This link goes to the "/editRegistration" action, which
* Prepopulates the form bean, and
* Forwards to the "/registration.jsp" page to display it with
  values from the "database".
* Then, the form is submitted to the "/saveRegistration" action,
  which validates the input (returning on any errors) or does
  the appropriate database action.

> Thanks,
> 
> Ranjit
> 
> 

Craig