You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vinicius Carvalho <vi...@auge.com.br> on 2004/09/30 19:33:51 UTC

Validator

Hi there! I've been using Struts for quite sometime, but haven't used 
the validator yet.
So I followed the receipt provided by Struts in Action, but got no 
success at all.

Here's what I've done

Struts-config is configured for the right plugin
My ActionForm extends ValidatorForm and has no validate() method

Validator-rules.xml:

    <validator name="required"
           classname="org.apache.struts.validator.FieldChecks"
              method="validateRequired"
        methodParams="java.lang.Object,
                      org.apache.commons.validator.ValidatorAction,
                      org.apache.commons.validator.Field,
                      org.apache.struts.action.ActionMessages,
                      javax.servlet.http.HttpServletRequest"
                 msg="validator.errors.required">
<javascript>
       <![CDATA[
       function validateRequired(form) {
         var isValid = true;
         var focusField = null;
         var i = 0;
         var fields = new Array();
         oRequired = new required();
         for (x in oRequired) {
           var field = form[oRequired[x][0]];

           if (field.type == 'text' ||
               field.type == 'textarea' ||
               field.type == 'file' ||
               field.type == 'select-one' ||
               field.type == 'radio' ||
               field.type == 'password') {

             var value = '';

             // get field's value
             if (field.type == "select-one") {
               var si = field.selectedIndex;
               if (si >= 0) {
                 value = field.options[si].value;
               }
             } else {
               value = field.value;
             }

             if (trim(value).length == 0) { {
               if (i == 0) {
                 focusField = field;
               }
               fields[i++] = oRequired[x][1];
               isValid = false;
             }
           }
         }

         if (fields.length > 0) {
           focusField.focus();
           alert(fields.join('\n'));
         }

         return isValid;
       }

       // Trim whitespace from left and right sides of s.
       function trim(s) {
         return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
       }

       ]]>
     </javascript>
     </validator>


validation.xml:

   <form name="userForm">
     <field property="nome" depends="required">
       <msg name="obrigatorio" key="validator.errors.required"/>
       <arg0 key="prompt.nome"/>
     </field>     </form> 
ApplicationResources.properties

validator.errors.required= O campo {0} é obrigatório
prompt.nome=nome


And my jsp file looks like this:

<html:form action="/atualizaDadosUsuarioAction" name="userForm" 
type="br.com.auge.errors.action.form.UserForm" onsubmit="return 
validateRequired(this)">
Nome <html:text property="nome" name="userForm"></html:text><html:errors 
/><br>
</html:form>
<html:javascript formName="userForm"/>


Well, what is happening is that after I submit with no values at all, 
nothing happens, it forwards to the
correct path. And also, the javascript generated isn't inside a 
<script></script> block. So it's printed
on the page footer.

Where did I miss?

Thanks

Vinicius

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


Re: Validator

Posted by Vinicius Carvalho <vi...@auge.com.br>.
David G. Friedman wrote:

>I haven't used the validator in a while but I have a 3 questions for you:
>
>1. If, as you say, the Javascript tag isn't being enclosed in
><script>..</script> tags, then you need to verify that your validation file
>is loaded AND that you have the correct form name in your <html:javascript
>formName="...." />.  I've had that problem before when the file either was
>not loaded (bad path on my part for the plug-in) OR when the formName="..."
>didn't match anything in my validation.xml file.  I recommend you make sure
>the file loaded properly and is in the correct path specified in your plugIn
>as you listed a matching formName in that .xml file.
>
>  
>
Well, first things first ;)
[ValidatorPlugIn] Loading validation rules file from 
'/WEB-INF/validator-rules.xml'
[ValidatorPlugIn] Loading validation rules file from 
'/WEB-INF/validation.xml'
 I guess this implies that it's been loaded right? Well the name of the 
form matches both javascript tag and validation.

>2. Since your html:javascript tag names the form "userForm", why isn't your
>action tag's onSubmit call this:
>onsubmit="return validateUserForm(this);"
>
>  
>
Sorry, this is what I didn't  understand. I thought that the name would 
be the name of the function declared on the validatior-rules.xml

>3. What does your action mapping look like?  I should look a bit like this
>(depending on how you customized it, of course):
>
><action path="/atualizaDadosUsuarioAction"
>	name="userForm"
>	type="AAAA"
>	validate="true"
>	input="BBBB" >
>	<forward name="success" path="????" />
></action>
>
>I. The "AAAA" should be the class name of the Action subclass to invoke.
>
>II. The validate="true" forces the server-side to user the userForm's
>validate() method provided by the super class ValidatorForm.  This allows
>validation failure to go to the place specified in the input="BBBB"
>attribute for your action in the struts-config.xml (or related Struts
>module) file.
>
>III. The "BBBB" should be a place to go (JSP, forward, html page, action) to
>go to when validation fails.  Typically, this is some input form page which
>is often the page calling the "/atualizaDadosUsuarioAction" Struts action in
>the first place.
>
>Regards,
>David
>
>
>  
>
Well step 3 looks just like above. I'll try other stuff here. But thanks 
for the help David.

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


RE: Validator

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
I haven't used the validator in a while but I have a 3 questions for you:

1. If, as you say, the Javascript tag isn't being enclosed in
<script>..</script> tags, then you need to verify that your validation file
is loaded AND that you have the correct form name in your <html:javascript
formName="...." />.  I've had that problem before when the file either was
not loaded (bad path on my part for the plug-in) OR when the formName="..."
didn't match anything in my validation.xml file.  I recommend you make sure
the file loaded properly and is in the correct path specified in your plugIn
as you listed a matching formName in that .xml file.

2. Since your html:javascript tag names the form "userForm", why isn't your
action tag's onSubmit call this:
onsubmit="return validateUserForm(this);"

3. What does your action mapping look like?  I should look a bit like this
(depending on how you customized it, of course):

<action path="/atualizaDadosUsuarioAction"
	name="userForm"
	type="AAAA"
	validate="true"
	input="BBBB" >
	<forward name="success" path="????" />
</action>

I. The "AAAA" should be the class name of the Action subclass to invoke.

II. The validate="true" forces the server-side to user the userForm's
validate() method provided by the super class ValidatorForm.  This allows
validation failure to go to the place specified in the input="BBBB"
attribute for your action in the struts-config.xml (or related Struts
module) file.

III. The "BBBB" should be a place to go (JSP, forward, html page, action) to
go to when validation fails.  Typically, this is some input form page which
is often the page calling the "/atualizaDadosUsuarioAction" Struts action in
the first place.

Regards,
David

-----Original Message-----
From: Vinicius Carvalho [mailto:vinicius@auge.com.br]
Sent: Friday, October 01, 2004 2:57 PM
To: Struts Users Mailing List
Subject: Re: Validator


Daniel H. F. e Silva wrote:

>Hi Gabriel,
>
>  When posting to the struts-users list, please, don't use any language
other than english.
>It is unpolite as just a few dudes here understand portuguese.
>  If you and all other Struts dudes (hey, i'm brazilian too) need help with
Struts, join the
>funkiest irc channel ever: #funkycodemonkey at irc.darkmyst.org.
>
>Cheers,
> Daniel Silva.
>
>
>
>--- Gabriel França Campolina <ga...@gmail.com> wrote:
>
>
>
>>Olá Vinicius,
>>
>>Poste o seu mapeamento de suas action no struts-config, e o mapeamento
>>dos seus form, para que eu possa analizar? Verifique o log gerado pelo
>>seu container web(Tomcat, JBoss etc), em geral eles listam a maioria
>>dos problemas da sua aplicação.
>>
>>Gabriel F Campolina
>>Analista desenvolvedor Java
>>Stefanini IT Solutions - BH
>>
>>
>>
>>On Thu, 30 Sep 2004 14:33:51 -0300, Vinicius Carvalho
>><vi...@auge.com.br> wrote:
>>
>>
>>>Hi there! I've been using Struts for quite sometime, but haven't used
>>>the validator yet.
>>>So I followed the receipt provided by Struts in Action, but got no
>>>success at all.
>>>
>>>Here's what I've done
>>>
>>>Struts-config is configured for the right plugin
>>>My ActionForm extends ValidatorForm and has no validate() method
>>>
>>>Validator-rules.xml:
>>>
>>>   <validator name="required"
>>>          classname="org.apache.struts.validator.FieldChecks"
>>>             method="validateRequired"
>>>       methodParams="java.lang.Object,
>>>                     org.apache.commons.validator.ValidatorAction,
>>>                     org.apache.commons.validator.Field,
>>>                     org.apache.struts.action.ActionMessages,
>>>                     javax.servlet.http.HttpServletRequest"
>>>                msg="validator.errors.required">
>>><javascript>
>>>      <![CDATA[
>>>      function validateRequired(form) {
>>>        var isValid = true;
>>>        var focusField = null;
>>>        var i = 0;
>>>        var fields = new Array();
>>>        oRequired = new required();
>>>        for (x in oRequired) {
>>>          var field = form[oRequired[x][0]];
>>>
>>>          if (field.type == 'text' ||
>>>              field.type == 'textarea' ||
>>>              field.type == 'file' ||
>>>              field.type == 'select-one' ||
>>>              field.type == 'radio' ||
>>>              field.type == 'password') {
>>>
>>>            var value = '';
>>>
>>>            // get field's value
>>>            if (field.type == "select-one") {
>>>              var si = field.selectedIndex;
>>>              if (si >= 0) {
>>>                value = field.options[si].value;
>>>              }
>>>            } else {
>>>              value = field.value;
>>>            }
>>>
>>>            if (trim(value).length == 0) { {
>>>              if (i == 0) {
>>>                focusField = field;
>>>              }
>>>              fields[i++] = oRequired[x][1];
>>>              isValid = false;
>>>            }
>>>          }
>>>        }
>>>
>>>        if (fields.length > 0) {
>>>          focusField.focus();
>>>          alert(fields.join('\n'));
>>>        }
>>>
>>>        return isValid;
>>>      }
>>>
>>>      // Trim whitespace from left and right sides of s.
>>>      function trim(s) {
>>>        return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
>>>      }
>>>
>>>      ]]>
>>>    </javascript>
>>>    </validator>
>>>
>>>validation.xml:
>>>
>>>  <form name="userForm">
>>>    <field property="nome" depends="required">
>>>      <msg name="obrigatorio" key="validator.errors.required"/>
>>>      <arg0 key="prompt.nome"/>
>>>    </field>     </form>
>>>ApplicationResources.properties
>>>
>>>validator.errors.required= O campo {0} é obrigatório
>>>prompt.nome=nome
>>>
>>>And my jsp file looks like this:
>>>
>>><html:form action="/atualizaDadosUsuarioAction" name="userForm"
>>>type="br.com.auge.errors.action.form.UserForm" onsubmit="return
>>>validateRequired(this)">
>>>Nome <html:text property="nome" name="userForm"></html:text><html:errors
>>>/><br>
>>></html:form>
>>><html:javascript formName="userForm"/>
>>>
>>>Well, what is happening is that after I submit with no values at all,
>>>nothing happens, it forwards to the
>>>correct path. And also, the javascript generated isn't inside a
>>><script></script> block. So it's printed
>>>on the page footer.
>>>
>>>Where did I miss?
>>>
>>>Thanks
>>>
>>>Vinicius
>>>
Well, it does has an error on console, I'm working on that right now, if
I don't get any success I'll cry for help again ;)

ps: NoSuchMethod Error ...

Gotta check my struts.jar versions....

---------------------------------------------------------------------
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: Validator

Posted by Vinicius Carvalho <vi...@auge.com.br>.
Daniel H. F. e Silva wrote:

>Hi Gabriel,
>
>  When posting to the struts-users list, please, don't use any language other than english.
>It is unpolite as just a few dudes here understand portuguese. 
>  If you and all other Struts dudes (hey, i'm brazilian too) need help with Struts, join the
>funkiest irc channel ever: #funkycodemonkey at irc.darkmyst.org.
>
>Cheers,
> Daniel Silva.
>
>
>
>--- Gabriel França Campolina <ga...@gmail.com> wrote:
>
>  
>
>>Olá Vinicius,
>>
>>Poste o seu mapeamento de suas action no struts-config, e o mapeamento
>>dos seus form, para que eu possa analizar? Verifique o log gerado pelo
>>seu container web(Tomcat, JBoss etc), em geral eles listam a maioria
>>dos problemas da sua aplicação.
>>
>>Gabriel F Campolina
>>Analista desenvolvedor Java
>>Stefanini IT Solutions - BH
>> 
>>
>>
>>On Thu, 30 Sep 2004 14:33:51 -0300, Vinicius Carvalho
>><vi...@auge.com.br> wrote:
>>    
>>
>>>Hi there! I've been using Struts for quite sometime, but haven't used
>>>the validator yet.
>>>So I followed the receipt provided by Struts in Action, but got no
>>>success at all.
>>>
>>>Here's what I've done
>>>
>>>Struts-config is configured for the right plugin
>>>My ActionForm extends ValidatorForm and has no validate() method
>>>
>>>Validator-rules.xml:
>>>
>>>   <validator name="required"
>>>          classname="org.apache.struts.validator.FieldChecks"
>>>             method="validateRequired"
>>>       methodParams="java.lang.Object,
>>>                     org.apache.commons.validator.ValidatorAction,
>>>                     org.apache.commons.validator.Field,
>>>                     org.apache.struts.action.ActionMessages,
>>>                     javax.servlet.http.HttpServletRequest"
>>>                msg="validator.errors.required">
>>><javascript>
>>>      <![CDATA[
>>>      function validateRequired(form) {
>>>        var isValid = true;
>>>        var focusField = null;
>>>        var i = 0;
>>>        var fields = new Array();
>>>        oRequired = new required();
>>>        for (x in oRequired) {
>>>          var field = form[oRequired[x][0]];
>>>
>>>          if (field.type == 'text' ||
>>>              field.type == 'textarea' ||
>>>              field.type == 'file' ||
>>>              field.type == 'select-one' ||
>>>              field.type == 'radio' ||
>>>              field.type == 'password') {
>>>
>>>            var value = '';
>>>
>>>            // get field's value
>>>            if (field.type == "select-one") {
>>>              var si = field.selectedIndex;
>>>              if (si >= 0) {
>>>                value = field.options[si].value;
>>>              }
>>>            } else {
>>>              value = field.value;
>>>            }
>>>
>>>            if (trim(value).length == 0) { {
>>>              if (i == 0) {
>>>                focusField = field;
>>>              }
>>>              fields[i++] = oRequired[x][1];
>>>              isValid = false;
>>>            }
>>>          }
>>>        }
>>>
>>>        if (fields.length > 0) {
>>>          focusField.focus();
>>>          alert(fields.join('\n'));
>>>        }
>>>
>>>        return isValid;
>>>      }
>>>
>>>      // Trim whitespace from left and right sides of s.
>>>      function trim(s) {
>>>        return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
>>>      }
>>>
>>>      ]]>
>>>    </javascript>
>>>    </validator>
>>>
>>>validation.xml:
>>>
>>>  <form name="userForm">
>>>    <field property="nome" depends="required">
>>>      <msg name="obrigatorio" key="validator.errors.required"/>
>>>      <arg0 key="prompt.nome"/>
>>>    </field>     </form>
>>>ApplicationResources.properties
>>>
>>>validator.errors.required= O campo {0} é obrigatório
>>>prompt.nome=nome
>>>
>>>And my jsp file looks like this:
>>>
>>><html:form action="/atualizaDadosUsuarioAction" name="userForm"
>>>type="br.com.auge.errors.action.form.UserForm" onsubmit="return
>>>validateRequired(this)">
>>>Nome <html:text property="nome" name="userForm"></html:text><html:errors
>>>/><br>
>>></html:form>
>>><html:javascript formName="userForm"/>
>>>
>>>Well, what is happening is that after I submit with no values at all,
>>>nothing happens, it forwards to the
>>>correct path. And also, the javascript generated isn't inside a
>>><script></script> block. So it's printed
>>>on the page footer.
>>>
>>>Where did I miss?
>>>
>>>Thanks
>>>
>>>Vinicius
>>>
>>>---------------------------------------------------------------------
>>>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
>>
>>
>>    
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>  
>
Well, it does has an error on console, I'm working on that right now, if 
I don't get any success I'll cry for help again ;)

ps: NoSuchMethod Error ...

Gotta check my struts.jar versions....

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


Re: Validator

Posted by "Daniel H. F. e Silva" <dh...@yahoo.com>.
Hi Gabriel,

  When posting to the struts-users list, please, don't use any language other than english.
It is unpolite as just a few dudes here understand portuguese. 
  If you and all other Struts dudes (hey, i'm brazilian too) need help with Struts, join the
funkiest irc channel ever: #funkycodemonkey at irc.darkmyst.org.

Cheers,
 Daniel Silva.



--- Gabriel Fran�a Campolina <ga...@gmail.com> wrote:

> Ol� Vinicius,
> 
> Poste o seu mapeamento de suas action no struts-config, e o mapeamento
> dos seus form, para que eu possa analizar? Verifique o log gerado pelo
> seu container web(Tomcat, JBoss etc), em geral eles listam a maioria
> dos problemas da sua aplica��o.
> 
> Gabriel F Campolina
> Analista desenvolvedor Java
> Stefanini IT Solutions - BH
>  
> 
> 
> On Thu, 30 Sep 2004 14:33:51 -0300, Vinicius Carvalho
> <vi...@auge.com.br> wrote:
> > Hi there! I've been using Struts for quite sometime, but haven't used
> > the validator yet.
> > So I followed the receipt provided by Struts in Action, but got no
> > success at all.
> > 
> > Here's what I've done
> > 
> > Struts-config is configured for the right plugin
> > My ActionForm extends ValidatorForm and has no validate() method
> > 
> > Validator-rules.xml:
> > 
> >    <validator name="required"
> >           classname="org.apache.struts.validator.FieldChecks"
> >              method="validateRequired"
> >        methodParams="java.lang.Object,
> >                      org.apache.commons.validator.ValidatorAction,
> >                      org.apache.commons.validator.Field,
> >                      org.apache.struts.action.ActionMessages,
> >                      javax.servlet.http.HttpServletRequest"
> >                 msg="validator.errors.required">
> > <javascript>
> >       <![CDATA[
> >       function validateRequired(form) {
> >         var isValid = true;
> >         var focusField = null;
> >         var i = 0;
> >         var fields = new Array();
> >         oRequired = new required();
> >         for (x in oRequired) {
> >           var field = form[oRequired[x][0]];
> > 
> >           if (field.type == 'text' ||
> >               field.type == 'textarea' ||
> >               field.type == 'file' ||
> >               field.type == 'select-one' ||
> >               field.type == 'radio' ||
> >               field.type == 'password') {
> > 
> >             var value = '';
> > 
> >             // get field's value
> >             if (field.type == "select-one") {
> >               var si = field.selectedIndex;
> >               if (si >= 0) {
> >                 value = field.options[si].value;
> >               }
> >             } else {
> >               value = field.value;
> >             }
> > 
> >             if (trim(value).length == 0) { {
> >               if (i == 0) {
> >                 focusField = field;
> >               }
> >               fields[i++] = oRequired[x][1];
> >               isValid = false;
> >             }
> >           }
> >         }
> > 
> >         if (fields.length > 0) {
> >           focusField.focus();
> >           alert(fields.join('\n'));
> >         }
> > 
> >         return isValid;
> >       }
> > 
> >       // Trim whitespace from left and right sides of s.
> >       function trim(s) {
> >         return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
> >       }
> > 
> >       ]]>
> >     </javascript>
> >     </validator>
> > 
> > validation.xml:
> > 
> >   <form name="userForm">
> >     <field property="nome" depends="required">
> >       <msg name="obrigatorio" key="validator.errors.required"/>
> >       <arg0 key="prompt.nome"/>
> >     </field>     </form>
> > ApplicationResources.properties
> > 
> > validator.errors.required= O campo {0} � obrigat�rio
> > prompt.nome=nome
> > 
> > And my jsp file looks like this:
> > 
> > <html:form action="/atualizaDadosUsuarioAction" name="userForm"
> > type="br.com.auge.errors.action.form.UserForm" onsubmit="return
> > validateRequired(this)">
> > Nome <html:text property="nome" name="userForm"></html:text><html:errors
> > /><br>
> > </html:form>
> > <html:javascript formName="userForm"/>
> > 
> > Well, what is happening is that after I submit with no values at all,
> > nothing happens, it forwards to the
> > correct path. And also, the javascript generated isn't inside a
> > <script></script> block. So it's printed
> > on the page footer.
> > 
> > Where did I miss?
> > 
> > Thanks
> > 
> > Vinicius
> > 
> > ---------------------------------------------------------------------
> > 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
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Validator

Posted by Gabriel França Campolina <ga...@gmail.com>.
Olá Vinicius,

Poste o seu mapeamento de suas action no struts-config, e o mapeamento
dos seus form, para que eu possa analizar? Verifique o log gerado pelo
seu container web(Tomcat, JBoss etc), em geral eles listam a maioria
dos problemas da sua aplicação.

Gabriel F Campolina
Analista desenvolvedor Java
Stefanini IT Solutions - BH
 


On Thu, 30 Sep 2004 14:33:51 -0300, Vinicius Carvalho
<vi...@auge.com.br> wrote:
> Hi there! I've been using Struts for quite sometime, but haven't used
> the validator yet.
> So I followed the receipt provided by Struts in Action, but got no
> success at all.
> 
> Here's what I've done
> 
> Struts-config is configured for the right plugin
> My ActionForm extends ValidatorForm and has no validate() method
> 
> Validator-rules.xml:
> 
>    <validator name="required"
>           classname="org.apache.struts.validator.FieldChecks"
>              method="validateRequired"
>        methodParams="java.lang.Object,
>                      org.apache.commons.validator.ValidatorAction,
>                      org.apache.commons.validator.Field,
>                      org.apache.struts.action.ActionMessages,
>                      javax.servlet.http.HttpServletRequest"
>                 msg="validator.errors.required">
> <javascript>
>       <![CDATA[
>       function validateRequired(form) {
>         var isValid = true;
>         var focusField = null;
>         var i = 0;
>         var fields = new Array();
>         oRequired = new required();
>         for (x in oRequired) {
>           var field = form[oRequired[x][0]];
> 
>           if (field.type == 'text' ||
>               field.type == 'textarea' ||
>               field.type == 'file' ||
>               field.type == 'select-one' ||
>               field.type == 'radio' ||
>               field.type == 'password') {
> 
>             var value = '';
> 
>             // get field's value
>             if (field.type == "select-one") {
>               var si = field.selectedIndex;
>               if (si >= 0) {
>                 value = field.options[si].value;
>               }
>             } else {
>               value = field.value;
>             }
> 
>             if (trim(value).length == 0) { {
>               if (i == 0) {
>                 focusField = field;
>               }
>               fields[i++] = oRequired[x][1];
>               isValid = false;
>             }
>           }
>         }
> 
>         if (fields.length > 0) {
>           focusField.focus();
>           alert(fields.join('\n'));
>         }
> 
>         return isValid;
>       }
> 
>       // Trim whitespace from left and right sides of s.
>       function trim(s) {
>         return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
>       }
> 
>       ]]>
>     </javascript>
>     </validator>
> 
> validation.xml:
> 
>   <form name="userForm">
>     <field property="nome" depends="required">
>       <msg name="obrigatorio" key="validator.errors.required"/>
>       <arg0 key="prompt.nome"/>
>     </field>     </form>
> ApplicationResources.properties
> 
> validator.errors.required= O campo {0} é obrigatório
> prompt.nome=nome
> 
> And my jsp file looks like this:
> 
> <html:form action="/atualizaDadosUsuarioAction" name="userForm"
> type="br.com.auge.errors.action.form.UserForm" onsubmit="return
> validateRequired(this)">
> Nome <html:text property="nome" name="userForm"></html:text><html:errors
> /><br>
> </html:form>
> <html:javascript formName="userForm"/>
> 
> Well, what is happening is that after I submit with no values at all,
> nothing happens, it forwards to the
> correct path. And also, the javascript generated isn't inside a
> <script></script> block. So it's printed
> on the page footer.
> 
> Where did I miss?
> 
> Thanks
> 
> Vinicius
> 
> ---------------------------------------------------------------------
> 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