struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Donald Dwoske" <>
Subject RE: Populating a Form from the Model before view
Date Thu, 07 Nov 2002 20:31:08 GMT

this example works by going through the action, so the
url you need to use must go through the action...


do not go through:

http://hostname/myPage.jsp   # your Action will not execute

What also might catch you is that by going through the
action, it forces the the validate() method of the
Form bean to be called, so if your validate fails,
your action will never get a chance to run, which in this
case is bad because you haven't populated your view yet!

I've got some smarts in my Form by using a hidden field
so that the validate method knows what the user is doing
so as not to fail if the model data has not been populated yet.

So I might edit data with http://hostname/'load'&id='jsmith'

and when clicking the save button on my page after editing, i
change the hidden text field named 'action' to be 'save'

In this way validate() knows to do something different in the
action='load' case as opposed to an action='save' case.

In the 'load' case, my required field may be only 'id' but in
the 'edit' case, i may have lots of required fields, 'firstName', 'ssn', etc...


-----Original Message-----
From: Marcus Biel []
Sent: Thursday, November 07, 2002 6:18 AM
Subject: Re: Populating a Form from the Model before view

Your Action ... (){
	perform(...ActionForm form..) {
		YourActionForm yourActionForm = (YourActionForm)form;
} schrieb:
> Hello,
> Could someone point out the process in Struts in which a Form is poulated form the model
before being viewed.
> Most of the examples for Struts assume the Form is origianlly populated from the view.
I looking for the **reverse solution**. The sort of workflow for editing data ?
> Best Regards
> Mark

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

View raw message