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]

Reply via email to