Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:javascript is displaying all the javascript on the browser

 
Arthur Ford
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using struts validator for the first time and It is giving me some nice headaches.

I have given this line in my jsp page -

What this does is I have the complete javascript displayed on the browser!!! Check out this(This is displayed on the browser) -

function validateFloatRange(form) { var isValid = true; var focusField = null; var i = 0; var fields = new Array(); oRange = new floatRange(); for (x in oRange) { var field = form[oRange[x][0]]; if ((field.type == 'text' || field.type == 'textarea') && (field.value.length......etc..


Let me put down the code I have written -
My validator form bean:


My struts-config.xml

........

........

My validation.xml



I have no clue where I seem to going wrong.
I tried setting

Any suggestions??
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The fact that your JavaScript is being displayed could mean that you've put it in the wrong place in your JSP. In my experience, the best place to put it is directly before your </html:form> tag.

A coupld of more things to mention:

1-By overriding the validate() method with your own logic, you have overridden the Struts Validator Framework logic. I'd suggest removing this method.

2-You should specify validate="true" in your action mapping in the struts-config.xml file to make sure that validation is performed for that action.
 
Arthur Ford
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have tried putting the tag inside the form. It doesnt work. My html was a hash of <html> and </html> tags. I removed them too. But still no luck. Do you think I shoudl check somethign else? Pretty wierd problem, eh?
 
divya chamarti
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
please try to use validator frame work by removing the validate() method from FormBean class as you are overriding the validate method so finally the validate method() of ValidatorForm class will not be called and second thing that provide html:javascript tag before html:html tag and also in html:form add onclick event
try out these
regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic