You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by th...@webmd.net on 2002/02/15 01:40:55 UTC

Can this be done at all using Form objects within struts framework

With struts,when using a Form, I'd like to be able to have the form
"pre-load" records prior to the form being displayed.
Actually, more than just that, I'd like to have a form that can be entered
in 3 different possible states:

- Insert state (in which case the form is empty)
- Edit/View state (in which I "preload" the rows from the database)
- Delete state (in which I "preload" the row from the database but have the
fields disabled).

The validation() method is great because it contains a reference to the
request object but I notice there is no "init()" or "preload()"
method that comes with the form that I could "check/set a state and
pre-load a row from the database" so that my getters would know
to use the record.

By writting a  constructor for the the form, I don't have access to the
request object.

How can this be done?     Is there a way to force the struts framework to
call a method on my form object (to load/initialize values) prior to the
form being displayed?

thanks,
Theron


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


Re: Can this be done at all using Form objects within struts framework

Posted by Keith <ke...@yahoo.com>.
What's the best way to handle data that is displayed on the page but not
updateable on a form?
In my Action I put it in the request for the JSP to pick up.

I used to put it in the formBean but didn't like the clutter it caused there.


--- Ted Husted <hu...@apache.org> wrote:
> The form shouldn't preload the records. You should use an Action to
> preload the records, put them on the form, and then forward to the JSP
> when it's all said and done. 
> 
> The form bean is part of the view. In a Model 2/MVC application, it
> should not interact with the model/database.
> 
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Java Web Development with Struts.
> -- Tel +1 585 737-3463.
> -- Web http://www.husted.com/struts/
> 
> 
> theron.kousek@webmd.net wrote:
> > 
> > With struts,when using a Form, I'd like to be able to have the form
> > "pre-load" records prior to the form being displayed.
> > Actually, more than just that, I'd like to have a form that can be entered
> > in 3 different possible states:
> > 
> > - Insert state (in which case the form is empty)
> > - Edit/View state (in which I "preload" the rows from the database)
> > - Delete state (in which I "preload" the row from the database but have the
> > fields disabled).
> > 
> > The validation() method is great because it contains a reference to the
> > request object but I notice there is no "init()" or "preload()"
> > method that comes with the form that I could "check/set a state and
> > pre-load a row from the database" so that my getters would know
> > to use the record.
> > 
> > By writting a  constructor for the the form, I don't have access to the
> > request object.
> > 
> > How can this be done?     Is there a way to force the struts framework to
> > call a method on my form object (to load/initialize values) prior to the
> > form being displayed?
> > 
> > thanks,
> > Theron
> > 
> > --
> > 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>
> 


__________________________________________________
Do You Yahoo!?
Got something to say? Say it better with Yahoo! Video Mail 
http://mail.yahoo.com

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


Re: Can this be done at all using Form objects within struts framework

Posted by Ted Husted <hu...@apache.org>.
The form shouldn't preload the records. You should use an Action to
preload the records, put them on the form, and then forward to the JSP
when it's all said and done. 

The form bean is part of the view. In a Model 2/MVC application, it
should not interact with the model/database.

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


theron.kousek@webmd.net wrote:
> 
> With struts,when using a Form, I'd like to be able to have the form
> "pre-load" records prior to the form being displayed.
> Actually, more than just that, I'd like to have a form that can be entered
> in 3 different possible states:
> 
> - Insert state (in which case the form is empty)
> - Edit/View state (in which I "preload" the rows from the database)
> - Delete state (in which I "preload" the row from the database but have the
> fields disabled).
> 
> The validation() method is great because it contains a reference to the
> request object but I notice there is no "init()" or "preload()"
> method that comes with the form that I could "check/set a state and
> pre-load a row from the database" so that my getters would know
> to use the record.
> 
> By writting a  constructor for the the form, I don't have access to the
> request object.
> 
> How can this be done?     Is there a way to force the struts framework to
> call a method on my form object (to load/initialize values) prior to the
> form being displayed?
> 
> thanks,
> Theron
> 
> --
> 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>