Its not mandatory to have a form associated with the action what happens in the back is ,the actionservlet will look for formbean in the struts-config ,if it exists an instance of it will be created and the data will be populated in that.If it doesnt have any action then it will just redirect the request to the particular action.
Karthik Guru
Ranch Hand
Joined: Mar 06, 2001
Posts: 1209
posted
0
Originally posted by Nicholas Cheung: In this case, how can I invoke the forward action?
For forms, when I click a button, I can submit the form and invoke the *action*, how does this work?
Nick
Ok this is confusing me now. I thought that the page that submits *to* this action may have a form associated with it but this action is not interested in that form. Do correct me.
thanks
David Hibbs
Ranch Hand
Joined: Dec 19, 2002
Posts: 374
posted
0
To clarify:
Actions *may* have a struts form associated with them. If they do, request parameters that match field names on that form will be populated into the form prior to invoking the action. Additionally, if validate is set to true on the action, the form validate method will be invoked prior to control reaching your action. If there are validation errors, control returns to the input page without ever reaching the action.
Actions can be invoked in many ways: * Direct request (i.e. the browser URL bar) * HTML form submit (Post/Get) * HTTP forward * HTTP redirect etc.
When control is transferred to the action, it may or may not use the form. If a form is associated with the action, it may cast it and pull values out. It may just pull values from request parameters. Or it may just forward somewhere else without ever looking at the form.
Hopefully this helps rather than hinders...
"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
john guthrie
Ranch Hand
Joined: Aug 05, 2002
Posts: 124
posted
0
there is nothing is struts that even requires you to use ActionForms. notice that the execute method passes in the http request as a parameter too, so you could use that to get all the form parameters.