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 Caldeira Carvalho <vi...@squadra.com.br> on 2005/03/15 17:22:03 UTC

Help with validator and xdoclet

Hello there! I'm using for the first time, xdoclet to create my 
validation.xml file (that really help)
But I got stuck in a point. I have a property that must be float and 
also greater than 0. Here's what I've tried:

    /**
     * @param limitePreAutorizacao The limitePreAutorizacao to set.
     * @struts.validator type="float"
     * msgkey="error.manterPlanoCobertura.valorLimite.incorreto"
     *
     * @struts.validator type="minLength"
     * msgkey="error.menor"
     *
     * @struts.validator-args
     * arg0resource="label.manterPlanoCobertura.limitePreAutorizacao"
     *
     * @struts.validator-args
     * arg1value="${var:minlength}" name="minlength"
     *
     * @struts.validator-var
     * name="minlength"
     * value="0"
     *
     */

This outputs :
    <field property="limitePreAutorizacao"
                     depends="float,minLength">
                  <msg
                    name="float"
                    key="error.manterPlanoCobertura.valorLimite.incorreto"/>
                  <msg
                    name="minLength"
                    key="error.menor"/>

                  <arg0
                    key="label.manterPlanoCobertura.limitePreAutorizacao"
                  />
                  <arg1
                    key="${var:minlength}"
                      resource="false"
                  />
                  <var>
                    <var-name>minlength</var-name>
                    <var-value>0</var-value>
                  </var>
              </field>
First I got surprised that no name was given form arg1 ... well ok.
So when I run the app leaving the field empty, an error is displayed

ERROR [Validator] No ValidatorAction named minLength found for field 
limitePreAutorizacao

Could someone give me a hint on that?

Thanks

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


Re: Help with validator and xdoclet

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
No, can't do that with any of the numeric validators :-(.... would be a good
addition though.

Currently the only way to do this is using standard validators shipped with
struts is using the  "mask" validator.

Niall

----- Original Message ----- 
From: "Vinicius Caldeira Carvalho" <vi...@squadra.com.br>
Sent: Tuesday, March 15, 2005 8:11 PM

> As they say, there's no horn on a horse forehead.... I was misspeling a
> property name...

> Well, it works fine now, just a question. Float validation is not
> working for a grouped number. eg:
> 1.200,50. it says it's an invalid number. Is it possible to inform the
> type of  grouping used (just we do on <fmt:formatNumber>) ?



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


Re: Help with validator and xdoclet

Posted by Vinicius Caldeira Carvalho <vi...@squadra.com.br>.
Niall Pemberton wrote:

>I think minlength is the wrong validator for what you're trying to do. It
>just checks the length of whats keyed in (i.e. the number of characters) ...
>seems like you want a minimum value....you could use floatRange for this.
>
>http://struts.apache.org/userGuide/dev_validator.html#builtin
>
>Having said that...when you say its not validating...does that include the
>"float" validator .... if you enter an invalid float does it give an error?
>
>If thats not working then you need to check through the configuration. Are
>there any errors from the validator PlugIn when the servlet starts up? If
>not configure logging for "debug" and see if you can see it trying to call
>the validator.
>
>Niall
>
>----- Original Message ----- 
>From: "Vinicius Caldeira Carvalho" <vi...@squadra.com.br>
>Sent: Tuesday, March 15, 2005 6:28 PM
>
>
>  
>
>>Vinicius Caldeira Carvalho wrote:
>>
>>    
>>
>>>Hello there! I'm using for the first time, xdoclet to create my
>>>validation.xml file (that really help)
>>>But I got stuck in a point. I have a property that must be float and
>>>also greater than 0. Here's what I've tried:
>>>
>>>
>>>
>>>      
>>>
>>Sorry all. But I was using the wrong name for the validator. But yet
>>it's not working, this time however, it's nor validating or outputing
>>errors on console.
>>
>>any suggestions would be welcome
>>
>>regards
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>  
>
As they say, there's no horn on a horse forehead.... I was misspeling a 
property name...

Well, it works fine now, just a question. Float validation is not 
working for a grouped number. eg:
1.200,50. it says it's an invalid number. Is it possible to inform the 
type of  grouping used (just we do on <fmt:formatNumber>) ?

Thanks


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


Re: Help with validator and xdoclet

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
I think minlength is the wrong validator for what you're trying to do. It
just checks the length of whats keyed in (i.e. the number of characters) ...
seems like you want a minimum value....you could use floatRange for this.

http://struts.apache.org/userGuide/dev_validator.html#builtin

Having said that...when you say its not validating...does that include the
"float" validator .... if you enter an invalid float does it give an error?

If thats not working then you need to check through the configuration. Are
there any errors from the validator PlugIn when the servlet starts up? If
not configure logging for "debug" and see if you can see it trying to call
the validator.

Niall

----- Original Message ----- 
From: "Vinicius Caldeira Carvalho" <vi...@squadra.com.br>
Sent: Tuesday, March 15, 2005 6:28 PM


> Vinicius Caldeira Carvalho wrote:
>
> > Hello there! I'm using for the first time, xdoclet to create my
> > validation.xml file (that really help)
> > But I got stuck in a point. I have a property that must be float and
> > also greater than 0. Here's what I've tried:
> >
> >
> >
> Sorry all. But I was using the wrong name for the validator. But yet
> it's not working, this time however, it's nor validating or outputing
> errors on console.
>
> any suggestions would be welcome
>
> regards



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


Re: Help with validator and xdoclet

Posted by Vinicius Caldeira Carvalho <vi...@squadra.com.br>.
Vinicius Caldeira Carvalho wrote:

> Hello there! I'm using for the first time, xdoclet to create my 
> validation.xml file (that really help)
> But I got stuck in a point. I have a property that must be float and 
> also greater than 0. Here's what I've tried:
>
>    /**
>     * @param limitePreAutorizacao The limitePreAutorizacao to set.
>     * @struts.validator type="float"
>     * msgkey="error.manterPlanoCobertura.valorLimite.incorreto"
>     *
>     * @struts.validator type="minLength"
>     * msgkey="error.menor"
>     *
>     * @struts.validator-args
>     * arg0resource="label.manterPlanoCobertura.limitePreAutorizacao"
>     *
>     * @struts.validator-args
>     * arg1value="${var:minlength}" name="minlength"
>     *
>     * @struts.validator-var
>     * name="minlength"
>     * value="0"
>     *
>     */
>
> This outputs :
>    <field property="limitePreAutorizacao"
>                     depends="float,minLength">
>                  <msg
>                    name="float"
>                    
> key="error.manterPlanoCobertura.valorLimite.incorreto"/>
>                  <msg
>                    name="minLength"
>                    key="error.menor"/>
>
>                  <arg0
>                    key="label.manterPlanoCobertura.limitePreAutorizacao"
>                  />
>                  <arg1
>                    key="${var:minlength}"
>                      resource="false"
>                  />
>                  <var>
>                    <var-name>minlength</var-name>
>                    <var-value>0</var-value>
>                  </var>
>              </field>
> First I got surprised that no name was given form arg1 ... well ok.
> So when I run the app leaving the field empty, an error is displayed
>
> ERROR [Validator] No ValidatorAction named minLength found for field 
> limitePreAutorizacao
>
> Could someone give me a hint on that?
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
Sorry all. But I was using the wrong name for the validator. But yet 
it's not working, this time however, it's nor validating or outputing 
errors on console.

any suggestions would be welcome

regards

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