You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Graham Lounder <lo...@caris.com> on 2002/07/08 20:46:34 UTC

Using Reset to Load Drop Downs?

Hell All,

I'm having a small problem with loading my drop downs after a validation
error (since my action is not being called again).  It is recomended/good
practice to load my drop downs in the reset method of the form?  Is it
possible?  I would load them once my application starts, but I need to
modify the list before it is displayed.

Any Ideas?
Graham

============================================
  Graham Lounder
  Java Developer
  Spatial Components Division
  CARIS
  264 Rookwood Ave
  Fredericton NB E3B-2M2
  Office 506 462-4218
  Fax    506 459-3849
  graham.lounder@caris.com
  http://www.spatialcomponents.com
============================================


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Using Reset to Load Drop Downs?

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Sorry, I was wrong - I don't load my dropdown lists in the form-reset 
method - I load my nested beans in the form reset. I load my dropdowns 
in beans instantiated in the JSPs.

I call them list beans and pretend that they're a justifiable exception 
(or extension) to the model to deal with the dropdown issue.

As long as they instantiate and call up the lists before the error tag, 
you also get error messages.


Adam


Joseph Barefoot wrote:
> When we discovered this problem, we said "screw automatic validation",
> turned it off for all action mappings, and resorted to calling the validate
> method(s) in our ActionForm from the action itself, passing in an
> ActionErrors object to be populated by these validate methods.  If the
> ActionErrors object isn't empty after this call (meaning there were errors),
> we reinit the form's fields (for drop-downs, etc.), save the ActionErrors
> object, and forward back to the page in question.
> 
> Not a perfect solution, but it keeps excess logic and DAO calls out of your
> ActionForm's reset method.
> 
> peace,
> Joe
> 
> 
>>-----Original Message-----
>>From: Graham Lounder [mailto:lounder@caris.com]
>>Sent: Wednesday, July 10, 2002 12:59 PM
>>To: Struts Users Mailing List
>>Subject: RE: Using Reset to Load Drop Downs?
>>
>>
>>Yeah, that is what I started to do, loading my drop downs in the
>>get method
>>if the list is null.  In the reset method I set my drop down
>>lists to null.
>>I thought about putting them in the session and came to the same
>>conclusion
>>as you, no way to determin when to get rid of them.
>>
>>Does anyone have a better solution to this problem?  I feel all dirty
>>putting logic in my forms.
>>
>>Graham
>>
>>-----Original Message-----
>>From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com]
>>Sent: Wednesday, July 10, 2002 4:15 PM
>>To: Struts Users Mailing List
>>Subject: Re: Using Reset to Load Drop Downs?
>>
>>
>>I do that. The problems include getting error messages out when
>>something goes wrong, and potentially fetching huge lists if the
>>parameters are wrong. Can't think of any others.
>>
>>I used to get the dropdown lists in the action, and store them in the
>>session, but I couldn't think of a way of getting rid of them from the
>>session easily.
>>
>>Adam
>>
>>
>>
>>Graham Lounder wrote:
>>
>>>Hell All,
>>>
>>>I'm having a small problem with loading my drop downs after a validation
>>>error (since my action is not being called again).  It is
>>
>>recomended/good
>>
>>>practice to load my drop downs in the reset method of the form?  Is it
>>>possible?  I would load them once my application starts, but I need to
>>>modify the list before it is displayed.
>>>
>>>Any Ideas?
>>>Graham
>>>
>>>============================================
>>>  Graham Lounder
>>>  Java Developer
>>>  Spatial Components Division
>>>  CARIS
>>>  264 Rookwood Ave
>>>  Fredericton NB E3B-2M2
>>>  Office 506 462-4218
>>>  Fax    506 459-3849
>>>  graham.lounder@caris.com
>>>  http://www.spatialcomponents.com
>>>============================================
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:
>>
>><ma...@jakarta.apache.org>
>>
>>>For additional commands, e-mail:
>>
>><ma...@jakarta.apache.org>
>>
>>>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Using Reset to Load Drop Downs?

Posted by Joseph Barefoot <jo...@hereuare.com>.
When we discovered this problem, we said "screw automatic validation",
turned it off for all action mappings, and resorted to calling the validate
method(s) in our ActionForm from the action itself, passing in an
ActionErrors object to be populated by these validate methods.  If the
ActionErrors object isn't empty after this call (meaning there were errors),
we reinit the form's fields (for drop-downs, etc.), save the ActionErrors
object, and forward back to the page in question.

Not a perfect solution, but it keeps excess logic and DAO calls out of your
ActionForm's reset method.

peace,
Joe

> -----Original Message-----
> From: Graham Lounder [mailto:lounder@caris.com]
> Sent: Wednesday, July 10, 2002 12:59 PM
> To: Struts Users Mailing List
> Subject: RE: Using Reset to Load Drop Downs?
>
>
> Yeah, that is what I started to do, loading my drop downs in the
> get method
> if the list is null.  In the reset method I set my drop down
> lists to null.
> I thought about putting them in the session and came to the same
> conclusion
> as you, no way to determin when to get rid of them.
>
> Does anyone have a better solution to this problem?  I feel all dirty
> putting logic in my forms.
>
> Graham
>
> -----Original Message-----
> From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com]
> Sent: Wednesday, July 10, 2002 4:15 PM
> To: Struts Users Mailing List
> Subject: Re: Using Reset to Load Drop Downs?
>
>
> I do that. The problems include getting error messages out when
> something goes wrong, and potentially fetching huge lists if the
> parameters are wrong. Can't think of any others.
>
> I used to get the dropdown lists in the action, and store them in the
> session, but I couldn't think of a way of getting rid of them from the
> session easily.
>
> Adam
>
>
>
> Graham Lounder wrote:
> > Hell All,
> >
> > I'm having a small problem with loading my drop downs after a validation
> > error (since my action is not being called again).  It is
> recomended/good
> > practice to load my drop downs in the reset method of the form?  Is it
> > possible?  I would load them once my application starts, but I need to
> > modify the list before it is displayed.
> >
> > Any Ideas?
> > Graham
> >
> > ============================================
> >   Graham Lounder
> >   Java Developer
> >   Spatial Components Division
> >   CARIS
> >   264 Rookwood Ave
> >   Fredericton NB E3B-2M2
> >   Office 506 462-4218
> >   Fax    506 459-3849
> >   graham.lounder@caris.com
> >   http://www.spatialcomponents.com
> > ============================================
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Using Reset to Load Drop Downs?

Posted by Graham Lounder <lo...@caris.com>.
Yeah, that is what I started to do, loading my drop downs in the get method
if the list is null.  In the reset method I set my drop down lists to null.
I thought about putting them in the session and came to the same conclusion
as you, no way to determin when to get rid of them.

Does anyone have a better solution to this problem?  I feel all dirty
putting logic in my forms.

Graham

-----Original Message-----
From: Adam Hardy [mailto:ahardy.struts@cyberspaceroad.com]
Sent: Wednesday, July 10, 2002 4:15 PM
To: Struts Users Mailing List
Subject: Re: Using Reset to Load Drop Downs?


I do that. The problems include getting error messages out when
something goes wrong, and potentially fetching huge lists if the
parameters are wrong. Can't think of any others.

I used to get the dropdown lists in the action, and store them in the
session, but I couldn't think of a way of getting rid of them from the
session easily.

Adam



Graham Lounder wrote:
> Hell All,
>
> I'm having a small problem with loading my drop downs after a validation
> error (since my action is not being called again).  It is recomended/good
> practice to load my drop downs in the reset method of the form?  Is it
> possible?  I would load them once my application starts, but I need to
> modify the list before it is displayed.
>
> Any Ideas?
> Graham
>
> ============================================
>   Graham Lounder
>   Java Developer
>   Spatial Components Division
>   CARIS
>   264 Rookwood Ave
>   Fredericton NB E3B-2M2
>   Office 506 462-4218
>   Fax    506 459-3849
>   graham.lounder@caris.com
>   http://www.spatialcomponents.com
> ============================================
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Using Reset to Load Drop Downs?

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
I do that. The problems include getting error messages out when 
something goes wrong, and potentially fetching huge lists if the 
parameters are wrong. Can't think of any others.

I used to get the dropdown lists in the action, and store them in the 
session, but I couldn't think of a way of getting rid of them from the 
session easily.

Adam



Graham Lounder wrote:
> Hell All,
> 
> I'm having a small problem with loading my drop downs after a validation
> error (since my action is not being called again).  It is recomended/good
> practice to load my drop downs in the reset method of the form?  Is it
> possible?  I would load them once my application starts, but I need to
> modify the list before it is displayed.
> 
> Any Ideas?
> Graham
> 
> ============================================
>   Graham Lounder
>   Java Developer
>   Spatial Components Division
>   CARIS
>   264 Rookwood Ave
>   Fredericton NB E3B-2M2
>   Office 506 462-4218
>   Fax    506 459-3849
>   graham.lounder@caris.com
>   http://www.spatialcomponents.com
> ============================================
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Using Reset to Load Drop Downs?

Posted by Ted Husted <hu...@apache.org>.
An Action should be used to populate anything needed by the form. In
this case, the input parameter should point to the Action that will
populate the controls rather than straight back to the JSP.

-- Ted Husted, Husted dot Com, Fairport NY US
-- Java Web Development with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


Graham Lounder wrote:
> 
> Hell All,
> 
> I'm having a small problem with loading my drop downs after a validation
> error (since my action is not being called again).  It is recomended/good
> practice to load my drop downs in the reset method of the form?  Is it
> possible?  I would load them once my application starts, but I need to
> modify the list before it is displayed.
> 
> Any Ideas?
> Graham
> 
> ============================================
>   Graham Lounder
>   Java Developer
>   Spatial Components Division
>   CARIS
>   264 Rookwood Ave
>   Fredericton NB E3B-2M2
>   Office 506 462-4218
>   Fax    506 459-3849
>   graham.lounder@caris.com
>   http://www.spatialcomponents.com
> ============================================
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>