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

Problem with <html:button .....

 
Naveen Mishra
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
document.forms[0].submit();

///// 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
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic