You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by alex <de...@yahoo.co.nz> on 2005/06/08 11:18:48 UTC

regularExpressionValidator

Hi,

I'm trying to use the regularExpressionValidator as follows:

In the faces-config.xml I set it up under a custom ID (here myID).

    <validator>
        <validator-id>myID</validator-id>
        
<validator-class>org.apache.myfaces.custom.regexprvalidator.RegExprValidator</validator-class>
        <property>
            <property-name>pattern</property-name>
            <property-class>java.lang.String</property-class>
            <default-value>aaa</default-value>
        </property>
    </validator>

Then I add it to an inputField in a bean:

Validator val = 
getApplication().createValidator("myID");                          
inputfield.addValidator(val);

With other validators like the lengthValidator this way works fine, 
however, the regexprValidator doesn't work. It seems, as if the pattern 
is always null.
Unfortunately the message of this validator doesn't show the 
regular-expression itself though this would be even more helpfull to the 
user than "the inserted value (some value) is not correct". Better would 
be "the inserted value (some value) doesn't match REGEX (<< the pattern 
set)".

Has anyone an idea how I can get it to work?

Regards
Alex

Re: regularExpressionValidator

Posted by alex <de...@yahoo.co.nz>.
I opened up a ticket in JIRA (MYFACES-279) and attached source, so that 
now the ErrorMessage shows the pattern which the input string must match.

Rgds
Alex

Re: regularExpressionValidator

Posted by alex <de...@yahoo.co.nz>.
Just because I cannot.
My jsp looks like this:

<f:view>
<h:form>
<h:panelGrid binding="#{somebean.inputGrid}" />
<h:commandButton value="submit" action="somebean.send" />
</h:form>
</f:view>

The inputform is built generic via component binding as you see. I never 
know, how many inputfields I would have and which validator has to be 
bound to it. This all comes out of an xml-file. That's why.

Richard Featherstone wrote:

>Alex,
>
>Not sure if this is any help but why not add the validation in your jsp like:
><h:inputText>
>	<x:validateRegExpr pattern=""/>
></h:inputText>
>
>Cheers,
>
>Ric
>  
>


Re: regularExpressionValidator

Posted by Richard Featherstone <rf...@transactgroup.net>.
Alex,

Not sure if this is any help but why not add the validation in your jsp like:
<h:inputText>
	<x:validateRegExpr pattern=""/>
</h:inputText>

Cheers,

Ric

On Wednesday 08 Jun 2005 10:18, alex wrote:
> Hi,
>
> I'm trying to use the regularExpressionValidator as follows:
>
> In the faces-config.xml I set it up under a custom ID (here myID).
>
>     <validator>
>         <validator-id>myID</validator-id>
>
> <validator-class>org.apache.myfaces.custom.regexprvalidator.RegExprValidato
>r</validator-class> <property>
>             <property-name>pattern</property-name>
>             <property-class>java.lang.String</property-class>
>             <default-value>aaa</default-value>
>         </property>
>     </validator>
>
> Then I add it to an inputField in a bean:
>
> Validator val =
> getApplication().createValidator("myID");
> inputfield.addValidator(val);
>
> With other validators like the lengthValidator this way works fine,
> however, the regexprValidator doesn't work. It seems, as if the pattern
> is always null.
> Unfortunately the message of this validator doesn't show the
> regular-expression itself though this would be even more helpfull to the
> user than "the inserted value (some value) is not correct". Better would
> be "the inserted value (some value) doesn't match REGEX (<< the pattern
> set)".
>
> Has anyone an idea how I can get it to work?
>
> Regards
> Alex