You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by pr...@seepz.tcs.co.in on 2003/07/22 12:12:05 UTC

Validator Problem

Hi,
I am using struts validator in the logon.jsp of my application.  If I don't
enter the username & click on submit the message displayed is "null is
required". Instead it should be "Username is required".
The part of the code in the validator-rules.xml is correct. I have given
msg="errors.required"
Also I have given "errors.required={0} is required."  &
"prompt.username=Username" in the ApplicationResources.properties file.
Still it is giving the same alert as "null is required" instead of
"Username" is required.

The corresponding part in the validation.xml is

            <field property="username"
                    depends="required, minlength,maxlength">
                <arg0   key="prompt.username"/>
                <arg1   key="${var:minlength}" name="minlength"
                   resource="false"/>
                <arg2   key="${var:maxlength}" name="maxlength"
                   resource="false"/>
                <var>
                    <var-name>maxlength</var-name>
                    <var-value>16</var-value>
                </var>
                <var>
                    <var-name>minlength</var-name>
                    <var-value>3</var-value>
                </var>
            </field>

Has anybody experienced this problem earlier ?


prashant.





Re: Validator Problem

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Hi Siva,

on a related problem, can you see what is wrong this the following xml, 
because I get the error message "title cannot be less than 2 characters" 
for the minlength validation, but I get "title cannot be more than null 
characters" for the maxlength validation.

<field property="title"
         depends="required,minlength,maxlength">
         <arg0   key="sections.validate.title"/>
         <arg1   key="${var:minlength}" name="minlength"
           resource="false"/>
         <arg2   key="${var:maxlength}" name="maxlength"
           resource="false"/>
         <var>
           <var-name>maxlength</var-name>
           <var-value>16</var-value>
         </var>
         <var>
           <var-name>minlength</var-name>
           <var-value>2</var-value>
         </var>
</field>

TIA
Adam

Siva wrote:
> Hi prashant,
> 
> In the validation.xml file, you have to give a name for the args. (how can it
> know that for what validation it has to use the args ?) So the arg0 shuld also
> contain a property called name="required"
> 
> Please let me know whether it works,
> 
> Sivakumar
> 
> 
> 
> prashant.mdesai@seepz.tcs.co.in wrote:
> 
> 
>>Hi,
>>I am using struts validator in the logon.jsp of my application.  If I don't
>>enter the username & click on submit the message displayed is "null is
>>required". Instead it should be "Username is required".
>>The part of the code in the validator-rules.xml is correct. I have given
>>msg="errors.required"
>>Also I have given "errors.required={0} is required."  &
>>"prompt.username=Username" in the ApplicationResources.properties file.
>>Still it is giving the same alert as "null is required" instead of
>>"Username" is required.
>>
>>The corresponding part in the validation.xml is
>>
>>            <field property="username"
>>                    depends="required, minlength,maxlength">
>>                <arg0   key="prompt.username"/>
>>                <arg1   key="${var:minlength}" name="minlength"
>>                   resource="false"/>
>>                <arg2   key="${var:maxlength}" name="maxlength"
>>                   resource="false"/>
>>                <var>
>>                    <var-name>maxlength</var-name>
>>                    <var-value>16</var-value>
>>                </var>
>>                <var>
>>                    <var-name>minlength</var-name>
>>                    <var-value>3</var-value>
>>                </var>
>>            </field>
>>
>>Has anybody experienced this problem earlier ?
>>
>>prashant.
>>
>>  ------------------------------------------------------------------------
>>                              Name: InterScan_SafeStamp.txt
>>   InterScan_SafeStamp.txt    Type: text/plain (text/plain)
>>                          Encoding: 7bit
>>
>>  ------------------------------------------------------------------------
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


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


Re: Validator Problem

Posted by Siva <si...@india.adventnet.com>.
Hi prashant,

In the validation.xml file, you have to give a name for the args. (how can it
know that for what validation it has to use the args ?) So the arg0 shuld also
contain a property called name="required"

Please let me know whether it works,

Sivakumar



prashant.mdesai@seepz.tcs.co.in wrote:

> Hi,
> I am using struts validator in the logon.jsp of my application.  If I don't
> enter the username & click on submit the message displayed is "null is
> required". Instead it should be "Username is required".
> The part of the code in the validator-rules.xml is correct. I have given
> msg="errors.required"
> Also I have given "errors.required={0} is required."  &
> "prompt.username=Username" in the ApplicationResources.properties file.
> Still it is giving the same alert as "null is required" instead of
> "Username" is required.
>
> The corresponding part in the validation.xml is
>
>             <field property="username"
>                     depends="required, minlength,maxlength">
>                 <arg0   key="prompt.username"/>
>                 <arg1   key="${var:minlength}" name="minlength"
>                    resource="false"/>
>                 <arg2   key="${var:maxlength}" name="maxlength"
>                    resource="false"/>
>                 <var>
>                     <var-name>maxlength</var-name>
>                     <var-value>16</var-value>
>                 </var>
>                 <var>
>                     <var-name>minlength</var-name>
>                     <var-value>3</var-value>
>                 </var>
>             </field>
>
> Has anybody experienced this problem earlier ?
>
> prashant.
>
>   ------------------------------------------------------------------------
>                               Name: InterScan_SafeStamp.txt
>    InterScan_SafeStamp.txt    Type: text/plain (text/plain)
>                           Encoding: 7bit
>
>   ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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