why, if I can write a javascript in validator-rules.xml, I should be able to able to get the dialog right. using confirm of javascript.

if I give below in jsp
<html:javascript formName="SetupForm" dynamicJavascript="true" staticJavascript="true" />

it works fine.

But I observed that the javascript is generated on client side. Which I don't want.

Is there a way to execute the javascript on server-side?

What are these dynamicJavascript and staticJavascript. When should these be set to true?


My application requirement is the users may not have javascript enabled on their browsers. Can I still use this html:javascript. Or is there any oher alternative to do this?

in validator-rules.xml

<validator name="populate"
           classname="org.apache.struts.validator.FieldChecks"
              method="changeInPopulate"
        methodParams="java.lang.Object,
                      org.apache.commons.validator.ValidatorAction,
                      org.apache.commons.validator.Field,
                      org.apache.struts.action.ActionMessages,
                      org.apache.commons.validator.Validator,
                      javax.servlet.http.HttpServletRequest"
             depends=""
                 msg="errors.setup">
        <javascript>
           <![CDATA[
               function changeInPopulate(autoPop){
                   var yesObj = document.getElementById("yesID");
                   var noObj = document.getElementById("noID");

                   if( (autoPop && (yesObj.checked))  ||
                       (!autoPop && (noObj.checked))   ) {
                       return;
                   }

                   var answer = confirm("are you sure");
                   if(!answer) {
                       if(yesObj.checked) {
                           noObj.checked=true;
                       }else {
                           yesObj.checked=true;
                       }
                   }
               }
           ]]>
        </javascript>
     </validator>




Thanks.



From: Laurie Harper <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: user@struts.apache.org
Subject: Re: javascript in validator
Date: Tue, 22 Nov 2005 23:43:57 -0500

fea jabi wrote:
One of the requirement in my application is that I should not use the client side javascript as the browsers the user use might not have the javascript enabled in their browsers.

In my jsp there are 2 radio buttons. one of which is enable by default. When the user clicks on either of those he/she should be promted with some message depending on which radio button they pressed Yes/No.

Using DynaValidatorForm.

Can I do this in struts validator xml? if so how to do this?

No, validator can check if a form is valid but it doesn't provide a way to generate arbitrary prompts and dialogs. Assuming you want something like an 'Are you sure you want to change this option? yes/no' prompt, you'll need to do that as a separate page.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to