How about if you use 3 different jsp file...
You can use 3 <html:submit/> with 3 different value
For example :
<html:submit value="confirm" property="action" />,
<html:submit value="registration" property="action" />,
<html:submit value="update" property="action" />,
and in Action class you can use this code :
------------------------------------------------------------
Assumption your ActionForm name is ActForm..
And your action class is act...
-----------------------------------------------------------
ActForm frm=(ActForm) form;
If(frm.getAction().equals("confirm")) return
mapping.findForward("action");
If(frm.getAction().equals("registration"))return
mapping.findForward("registration");
If(frm.getAction().equals("update")) return
mapping.findForward("update");
------------------------------------------------------------------------
----
and you have to set struts-config.xml with this following code :
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD
Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name=" ActForm " type="pak. ActForm "/>
</form-beans>
<action-mappings>
<action path="/halAction" type="pak.act" name=" ActForm " input="/
registration.jsp " scope="request">
<forward name=" action " path="/ registration.jsp "/>
<forward name=" registration " path="/ registration2.jsp "/>
<forward name="update" path="/ registration3.jsp "/>
</action>
</action-mappings>
<message-resources parameter="pak.ApplicationResources"/>
</struts-config>
-----Original Message-----
From: Andrew Hill [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 03, 2003 10:07 AM
To: Struts Users Mailing List; yan
Subject: RE: help: request.getParameter("action")
Firstly I should point out that naming a field (and a submit button
qualifies in this category) on your form "action" is a very bad idea (as
it
shadows the action property of the form object in the client side object
model - so if you ever need to play with a forms action path in
javascript
on the client side you will find you cant get at it! (you should in
general
avoid naming your form properties the same as anything thats a (js) form
object method or property. "submit" is another fun one - you should
never
name your submit button "submit"! hehe)... ) (It doesnt help that half
the
struts examples make this egregious mistake!)
Ok. Now getting on to your question. I the html:form tag does not have a
'value' attribute.
What you need is to use an html:submit tag to render your submit button.
ie:
<html:submit property="action" value="confirm"/>. The submit tag (which
just
renders the html <input name="action" type="submit" value="confirm"/>)
takes
a 'value' attribute. This is what will be submitted in the 'action'
request
parameter. It is however _also_ what gets displayed as the label on the
button! (If you are using i18n you will want to go take a look at the
javadocs for LookupDispatchAction at this point). The easiest way round
this
label_is_value issue is to make 'action' a hidden field and the button
they
click sets it in javascript and submits the form - however that only
works
if javascript is enabled.
And I'll mention it one last time: DONT CALL THE PARAMETER "action" !!!!
Thats bad. Call it "doAction" or "method" or "bob" but naming it the
same as
properties of the js form object (ie: action, submit, elements, etc...)
is
not a great idea....
-----Original Message-----
From: yan [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 2 September 2003 23:28
To: [EMAIL PROTECTED]
Subject: help: request.getParameter("action")
I am using a single jsp (registration.jsp) that can be used in one of
three
different ways:
1. create a new registration, user clicks on hyperlink
<html:link page="/editRegistration.do?action=create">
2. edit existing registration details, user clicks on hyperlink
<html:link page="/editRegistration.do?action=edit">
3. user confirms a new registation or confirms update existing details
(i.e registration.jsp is used to display to the user the fields they are
about to commit to the database)
in this case, the user will click on a BUTTON, not a hyperlink:
<html:form "action="/editRegistration.do" value="confirm">
In my EditRegistrationAction class, I want to check the the value of the
'action' attribute:
String action = request.getParameter("action")
My problem is that I am not sure if the value="confirm" attribute/value
pair
on the button will be detected by the request.getParameter("action")
method.
Will I therefore need a separate variable to check for the button i.e.
String value = request.getParameter("value")
many thanks
yan
Kickstart e Solutions. - Intelligent Web Services
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]