You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sai reddy <du...@gmail.com> on 2008/01/09 12:24:30 UTC

Problem using client side form validation feature. Friends, please help!!!

I'm using struts 1.2.7 version.

I wanted to validate a form client side. I used <html:javascript/> tag 
with 'formName' attribute set to the form-bean's logical name in 
struts-config.xml.
Inside validation.xml file, i set "depends" attribute's value as 
"required" ( i just wanted these form fields to be non white spaces ).

Now, the actual problem is that all the javascript code gets generated 
as the HTML output. I mean i just wanted to check if the form-fields 
have non-white space characters or not. But unnecessarily all other 
javascript code like "validateFloat", "validateDate", "validateEmail" 
validation code is being generated.


Please tell me where did it go wrong??


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem using client side form validation feature. Friends, please help!!!

Posted by Laurie Harper <la...@holoweb.net>.
This is normal. From the documentation for the html:javascript tag [1]

"... The dynamicJavascript and staticJavascript attributes default to 
true, but if dynamicJavascript is set to <code>true</code>  and 
staticJavascript is set to <code>false</code> then only the dynamic 
JavaScript will be rendered. If dynamicJavascript is set to 
<code>false</code>  and staticJavascript is set to <code>true</code> 
then only the static JavaScript will be rendered which can then be put 
in separate JSP page so the browser can cache the static JavaScript."

What you are seeing is the static part. Try setting staticJavascript to 
false to see the difference. I think that will give you what you want in 
your page, but note that you still need to make that static code 
available to the page.

To do that, create a JSP to render just the static Javascript (i.e. a 
JSP with an html:javascript tag, where dynamicJavascript is set to false 
and staticJavascript is set to true). Then reference that JSP from a 
<script> tag in the original page.

L.

[1] 
http://struts.apache.org/1.3.9/struts-taglib/tagreference.html#javascript

sai reddy wrote:
> Why does struts generate unnecessary javascript  in  the HTML page??
> Is there any way to stop struts from generating the extra javascript??
> 
> Ingo Villnow wrote:
>> I think it's quite normal that the whole javascript code is generated 
>> in the HTML output when you use client-side validation or are my 
>> thoughts wrong?
>>
>> sai reddy schrieb:
>>> I'm using struts 1.2.7 version.
>>>
>>> I wanted to validate a form client side. I used <html:javascript/> 
>>> tag with 'formName' attribute set to the form-bean's logical name in 
>>> struts-config.xml.
>>> Inside validation.xml file, i set "depends" attribute's value as 
>>> "required" ( i just wanted these form fields to be non white spaces ).
>>>
>>> Now, the actual problem is that all the javascript code gets 
>>> generated as the HTML output. I mean i just wanted to check if the 
>>> form-fields have non-white space characters or not. But unnecessarily 
>>> all other javascript code like "validateFloat", "validateDate", 
>>> "validateEmail" validation code is being generated.
>>>
>>>
>>> Please tell me where did it go wrong??
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> ------------------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem using client side form validation feature. Friends, please help!!!

Posted by sai reddy <du...@gmail.com>.
Why does struts generate unnecessary javascript  in  the HTML page??
Is there any way to stop struts from generating the extra javascript??

Ingo Villnow wrote:
> I think it's quite normal that the whole javascript code is generated 
> in the HTML output when you use client-side validation or are my 
> thoughts wrong?
>
> sai reddy schrieb:
>> I'm using struts 1.2.7 version.
>>
>> I wanted to validate a form client side. I used <html:javascript/> 
>> tag with 'formName' attribute set to the form-bean's logical name in 
>> struts-config.xml.
>> Inside validation.xml file, i set "depends" attribute's value as 
>> "required" ( i just wanted these form fields to be non white spaces ).
>>
>> Now, the actual problem is that all the javascript code gets 
>> generated as the HTML output. I mean i just wanted to check if the 
>> form-fields have non-white space characters or not. But unnecessarily 
>> all other javascript code like "validateFloat", "validateDate", 
>> "validateEmail" validation code is being generated.
>>
>>
>> Please tell me where did it go wrong??
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem using client side form validation feature. Friends, please help!!!

Posted by sai reddy <du...@gmail.com>.
Why does struts generate unnecessary javascript  in  the HTML page??
Is there any way to stop struts from generating the extra javascript??

Ingo Villnow wrote:
> I think it's quite normal that the whole javascript code is generated 
> in the HTML output when you use client-side validation or are my 
> thoughts wrong?
>
> sai reddy schrieb:
>> I'm using struts 1.2.7 version.
>>
>> I wanted to validate a form client side. I used <html:javascript/> 
>> tag with 'formName' attribute set to the form-bean's logical name in 
>> struts-config.xml.
>> Inside validation.xml file, i set "depends" attribute's value as 
>> "required" ( i just wanted these form fields to be non white spaces ).
>>
>> Now, the actual problem is that all the javascript code gets 
>> generated as the HTML output. I mean i just wanted to check if the 
>> form-fields have non-white space characters or not. But unnecessarily 
>> all other javascript code like "validateFloat", "validateDate", 
>> "validateEmail" validation code is being generated.
>>
>>
>> Please tell me where did it go wrong??
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem using client side form validation feature. Friends, please help!!!

Posted by Ingo Villnow <in...@googlemail.com>.
I think it's quite normal that the whole javascript code is generated in 
the HTML output when you use client-side validation or are my thoughts 
wrong?

sai reddy schrieb:
> I'm using struts 1.2.7 version.
>
> I wanted to validate a form client side. I used <html:javascript/> tag 
> with 'formName' attribute set to the form-bean's logical name in 
> struts-config.xml.
> Inside validation.xml file, i set "depends" attribute's value as 
> "required" ( i just wanted these form fields to be non white spaces ).
>
> Now, the actual problem is that all the javascript code gets generated 
> as the HTML output. I mean i just wanted to check if the form-fields 
> have non-white space characters or not. But unnecessarily all other 
> javascript code like "validateFloat", "validateDate", "validateEmail" 
> validation code is being generated.
>
>
> Please tell me where did it go wrong??
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>