File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Problem with  <html:button ..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with  &lt;html:button ....." Watch "Problem with  &lt;html:button ....." New topic

Problem with &lt;html:button .....

Naveen Mishra
Ranch Hand

Joined: Nov 20, 2005
Posts: 75
I'm using struts 1.1 along with wsad 5.1.2
In jsp file there is a problem :

Following code does not allow me to submit the form (i'm using javascript for validation of the form . It gives error message ( in javascript) saying "Object does not support this property or method' at line

///// pls read onclik as onclick

but , when I changed the property of button to some thing else it works fine...

what is wrong in giving property as some reserve keyword ? as it is passed to the tld as an String literal only .

any good reason which works behind the seen or some bug in tld ?

Thanks .
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
This problem has nothing to do with the Struts tag libraries. It has to do with JavaScript.

The tag <html:button property="submit" /> will be rendered as <input type="button" name="submit>. In terms of JavaScript This means that you've replaced the submit property of the forms[0] object with a button object. In JavaScript, a method is a property, so the existing submit() method of forms[0] is also a property. When you add a button named "submit", you replace the submit() method with a button object, thereby making it impossible to submit the form through JavaScript.

The moral of the story: Never name a button "submit" on your form. Also avoid any of the form object's other method names such as reset, focus, etc.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Problem with &lt;html:button .....
jQuery in Action, 3rd edition