You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by laredotornado <la...@gmail.com> on 2010/03/02 21:58:04 UTC

Re: Help with regular expression

Thanks but I don't want to do that because if validation fails for both cases
(regular expression and length vaildator) then two error messages will be
displayed and I just want to have a single error message (e.g. "Email
address must be of the form ... and between 1 and x characters long.")


 - Dave


Richard Yee-3 wrote:
> 
> Use a separate validator for length
> 
> Richard
> 
> Sent from my iPhone
> 
> On Feb 26, 2010, at 9:29 AM, laredotornado <la...@gmail.com>  
> wrote:
> 
>>
>> Hi,
>>
>> I'm using MyFaces 1.1.5 and Tomahawk 1.1.7.  I am using a regexp to  
>> validate
>> a text field and I was wondering how do I rewrite/add to it to  
>> indicate that
>> the total amount of characters should be between 1 and 320?  Here is  
>> what I
>> have now ...
>>
>> <t:validateRegExpr
>> pattern="[\w\-\+\&\*]+(?:\.[\w\-\_\+\&\*]+)*@(?:[\w-]+\.)+[a-zA-Z] 
>> {2,7}$" />
>>
>> Thanks for any feedback, - Dave
>> -- 
>> View this message in context:
>> http://old.nabble.com/Help-with-regular-expression-tp27721131p27721131.html
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/Help-with-regular-expression-tp27721131p27761087.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Help with regular expression

Posted by Richard Yee <ri...@gmail.com>.
Are you using h:message or h:messages to display the error message? If you
should use h:message I think only one message will be displayed.

_R

On Tue, Mar 2, 2010 at 8:04 PM, Richard Yee <ri...@gmail.com> wrote:

> there are several options for handling this.
> 1) If you use two validators and only want one message to be displayed, you
> can use a phase listener to detect the condition and remove the extra
> message
> 2) You can use a validator method in your backing bean to handle both
> validations and display the appropriate error message.
> 3) You can write your own custom validator to do both validations. With
> this approach, the validator could be used easily in multiple pages.
>
> -R
>
>
> On Tue, Mar 2, 2010 at 12:58 PM, laredotornado <la...@gmail.com>wrote:
>
>>
>> Thanks but I don't want to do that because if validation fails for both
>> cases
>> (regular expression and length vaildator) then two error messages will be
>> displayed and I just want to have a single error message (e.g. "Email
>> address must be of the form ... and between 1 and x characters long.")
>>
>>
>>  - Dave
>>
>>
>> Richard Yee-3 wrote:
>> >
>> > Use a separate validator for length
>> >
>> > Richard
>> >
>> > Sent from my iPhone
>> >
>> > On Feb 26, 2010, at 9:29 AM, laredotornado <la...@gmail.com>
>> > wrote:
>> >
>> >>
>> >> Hi,
>> >>
>> >> I'm using MyFaces 1.1.5 and Tomahawk 1.1.7.  I am using a regexp to
>> >> validate
>> >> a text field and I was wondering how do I rewrite/add to it to
>> >> indicate that
>> >> the total amount of characters should be between 1 and 320?  Here is
>> >> what I
>> >> have now ...
>> >>
>> >> <t:validateRegExpr
>> >> pattern="[\w\-\+\&\*]+(?:\.[\w\-\_\+\&\*]+)*@(?:[\w-]+\.)+[a-zA-Z]
>> >> {2,7}$" />
>> >>
>> >> Thanks for any feedback, - Dave
>> >> --
>> >> View this message in context:
>> >>
>> http://old.nabble.com/Help-with-regular-expression-tp27721131p27721131.html
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Help-with-regular-expression-tp27721131p27761087.html
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
>

Re: Help with regular expression

Posted by Richard Yee <ri...@gmail.com>.
there are several options for handling this.
1) If you use two validators and only want one message to be displayed, you
can use a phase listener to detect the condition and remove the extra
message
2) You can use a validator method in your backing bean to handle both
validations and display the appropriate error message.
3) You can write your own custom validator to do both validations. With this
approach, the validator could be used easily in multiple pages.

-R

On Tue, Mar 2, 2010 at 12:58 PM, laredotornado <la...@gmail.com>wrote:

>
> Thanks but I don't want to do that because if validation fails for both
> cases
> (regular expression and length vaildator) then two error messages will be
> displayed and I just want to have a single error message (e.g. "Email
> address must be of the form ... and between 1 and x characters long.")
>
>
>  - Dave
>
>
> Richard Yee-3 wrote:
> >
> > Use a separate validator for length
> >
> > Richard
> >
> > Sent from my iPhone
> >
> > On Feb 26, 2010, at 9:29 AM, laredotornado <la...@gmail.com>
> > wrote:
> >
> >>
> >> Hi,
> >>
> >> I'm using MyFaces 1.1.5 and Tomahawk 1.1.7.  I am using a regexp to
> >> validate
> >> a text field and I was wondering how do I rewrite/add to it to
> >> indicate that
> >> the total amount of characters should be between 1 and 320?  Here is
> >> what I
> >> have now ...
> >>
> >> <t:validateRegExpr
> >> pattern="[\w\-\+\&\*]+(?:\.[\w\-\_\+\&\*]+)*@(?:[\w-]+\.)+[a-zA-Z]
> >> {2,7}$" />
> >>
> >> Thanks for any feedback, - Dave
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/Help-with-regular-expression-tp27721131p27721131.html
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Help-with-regular-expression-tp27721131p27761087.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>