You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alex Colic <Al...@pop-ware.com> on 2002/02/20 19:55:09 UTC
How to set attribute via submit
Hi,
I have a form with a couple of buttons. The form is submitted to a
navigation action class that just looks at an action parameters and forwards
the request. I want created a series of submit buttons with the same
property but different values. If I set the value property of the tag then
that is displayed as the text of the button. What I need to do is set the
property and value of the button with a different String for the text
displayed on the button.
Any ideas?
Thanks
Alex
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: How to set attribute via submit
Posted by Victor Hadianto <vi...@nuix.com.au>.
> same property but different values. If I set the value property of the tag
> then that is displayed as the text of the button. What I need to do is set
> the property and value of the button with a different String for the text
> displayed on the button.
Hi Alex,
This is quite hard to achieve because the way Http POST works. When you click
on the submit button, the request object contains the following pair:
button name, button text
There are several workarounds to find out which button you click on the form.
But the easiest way is to declare a setter method on your form that matches
the button name and in that setter method you set a variable in your form to
identify which button that the user selects.
IE:
public void setButtonDelete(String ignore) {
action = DELETE_ACTION;
}
public void perform(...) {
switch (form.getAction())
{
case DELETE_ACTION:
...
}
}
If your buttons MUST have all the same name, then the only way to do this is
for your form bean to know the list of the button labels and sets the action
accordingly.
HTH,
--
Victor Hadianto
---------------
He who laughs, lasts.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>