File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Buttons EventHandler and Property-Setting

 
Ren� Thol
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I've got a question regarding struts and HTML-Buttons.

As soon as I connect an event-handler (for example onclick) with the button which causes a submission of the surrounding form, the button's property itself is not set.

So it seems that the browser first handles the event handlers of an HTML element before it sets the appropriate values into the fields of the appropriate element (for me: the button)!

Is there any way to get the value of the button when submitting the form with an event handler connected to the button?

Currently I'm sending the button's value as a request parameter attached to the URL the event handler calls (not my favourite solution though)!

Many thanks in advanvce
Best Regards
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HTML, when you have a conrol such as:
or

The assumption is that you're using this button only for its onclick event, and the value attribute is not submitted to the server. (Note that <html:button/> gets translated to <input type="button">). Passing the value as a parameter as you're doing is about as good a way of handing it as any.
[ November 07, 2007: Message edited by: Merrill Higginson ]
 
Brent Sterling
Ranch Hand
Posts: 948
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also define a property on your form, define a hidden field on your jsp and then set the value of the hidden field in your onclick handler. That way you would not have to pass the value on the URL and in your action you can read the value directly from the form class.

- Brent
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic