You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Bjørn T Johansen <bt...@havleik.no> on 2006/05/04 08:51:49 UTC

How to write a customized valdation, that validate by comparing one field to another_

I need to validate two fields on my webpage, two dates, and I need to check if one date is greater than the
other. Is this possible? Have I access to the other fields from within my validate method or is there another
way of doing this (or do I have to check this in my save method)?


Regards,

BTJ

-- 
-----------------------------------------------------------------------------------------------
Bjørn T Johansen

btj@havleik.no
-----------------------------------------------------------------------------------------------
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"
-----------------------------------------------------------------------------------------------

Re: How to write a customized valdation, that validate by comparing one field to another_

Posted by Murat Hazer <mu...@gmail.com>.
As far as i know validation in the JSF spec is component based, so if you
want to validate a form (like you) you should follow a different way, you
can add a hidden input after the components you want validate and write your
validator method to this hidden component validator. (You can read detail of
this trick at the Core Faces book's validation section, it is avaible online
http://www.horstmann.com/corejsf/).
When following this way i encountered a different problem, i could not get
the request values (model values  are not updated at the validation phase)
at the validation phase, so i added dataModel.processUpdates(facesContext)
line into the validation method. Advanced developers may advice a different
way may be?


regards...

On 5/4/06, Bjørn T Johansen <bt...@havleik.no> wrote:
>
> I need to validate two fields on my webpage, two dates, and I need to
> check if one date is greater than the
> other. Is this possible? Have I access to the other fields from within my
> validate method or is there another
> way of doing this (or do I have to check this in my save method)?
>
>
> Regards,
>
> BTJ
>
> --
>
> -----------------------------------------------------------------------------------------------
> Bjørn T Johansen
>
> btj@havleik.no
>
> -----------------------------------------------------------------------------------------------
> Someone wrote:
> "I understand that if you play a Windows CD backwards you hear strange
> Satanic messages"
> To which someone replied:
> "It's even worse than that; play it forwards and it installs Windows"
>
> -----------------------------------------------------------------------------------------------
>



--
Murat HAZER
Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
Tel - Phone: +90 222 335 05 80 - 1395
Cep Tel - Mobile Phone: +90 532 472 00 63
Blog URL: http://www.projedunyasi.org
Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/

Re: How to write a customized valdation, that validate by comparing one field to another_

Posted by Mike Kienenberger <mk...@gmail.com>.
validateCompareTo is exactly what you need, and it's stable.  I wrote
it to compare date fields, so this is its most-tested configuration :)

I'll probably push to have it promoted from the sandbox to tomahawk pretty soon.
The only issues holding it back (that I know of) are that there are
some hardcoded strings in the code that need to be moved to
localizable message properties.

If you'd like to speed up the promotion process, feel free to submit
patches fix this issue.

On 5/4/06, Bjørn T Johansen <bt...@havleik.no> wrote:
> How stable is the components in sandbox?
>
> BTJ
>
> On Thu, 04 May 2006 09:45:55 +0200
> Volker Weber <us...@weber-oldenburg.de> wrote:
>
> > Hi,
> >
> > there is a validateCompareTo tag in sandbox
> >
> > http://myfaces.apache.org/sandbox/validateCompareTo.html
> > http://myfaces.apache.org/sandbox/tlddoc/s/validateCompareTo.html

Re: How to write a customized valdation, that validate by comparing one field to another_

Posted by Bjørn T Johansen <bt...@havleik.no>.
How stable is the components in sandbox?

BTJ

On Thu, 04 May 2006 09:45:55 +0200
Volker Weber <us...@weber-oldenburg.de> wrote:

> Hi,
> 
> there is a validateCompareTo tag in sandbox
> 
> http://myfaces.apache.org/sandbox/validateCompareTo.html
> http://myfaces.apache.org/sandbox/tlddoc/s/validateCompareTo.html
> 
> 
> Regards,
>   Volker
> 
> 
> Le Van wrote:
> > You could do it using validator. Read "*JavaServer Faces" of Hans
> > Bergsten.*
> > Bjørn T Johansen wrote:
> > 
> >> I need to validate two fields on my webpage, two dates, and I need to
> >> check if one date is greater than the
> >> other. Is this possible? Have I access to the other fields from within
> >> my validate method or is there another
> >> way of doing this (or do I have to check this in my save method)?
> >>
> >>
> >> Regards,
> >>
> >> BTJ
> >>
> >>  
> >>

RE: How to write a customized valdation, that validate by comparing one field to another_

Posted by Julian Ray <ju...@yahoo.com>.
+1 for validateCompareTo. This is an extremely useful validator which we use
extensively. 

-----Original Message-----
From: Volker Weber [mailto:users.myfaces@weber-oldenburg.de] 
Sent: Thursday, May 04, 2006 3:46 AM
To: MyFaces Discussion
Subject: Re: How to write a customized valdation, that validate by comparing
one field to another_

Hi,

there is a validateCompareTo tag in sandbox

http://myfaces.apache.org/sandbox/validateCompareTo.html
http://myfaces.apache.org/sandbox/tlddoc/s/validateCompareTo.html


Regards,
  Volker


Le Van wrote:
> You could do it using validator. Read "*JavaServer Faces" of Hans
> Bergsten.*
> Bjørn T Johansen wrote:
> 
>> I need to validate two fields on my webpage, two dates, and I need to 
>> check if one date is greater than the other. Is this possible? Have I 
>> access to the other fields from within my validate method or is there 
>> another way of doing this (or do I have to check this in my save 
>> method)?
>>
>>
>> Regards,
>>
>> BTJ
>>
>>  
>>
> 

--
Don't answer to From: address!
Mail to this account are droped if not recieved via mailinglist.
To contact me direct create the mail address by concatenating my forename to
my senders domain.


Re: How to write a customized valdation, that validate by comparing one field to another_

Posted by Volker Weber <us...@weber-oldenburg.de>.
Hi,

there is a validateCompareTo tag in sandbox

http://myfaces.apache.org/sandbox/validateCompareTo.html
http://myfaces.apache.org/sandbox/tlddoc/s/validateCompareTo.html


Regards,
  Volker


Le Van wrote:
> You could do it using validator. Read "*JavaServer Faces" of Hans
> Bergsten.*
> Bjørn T Johansen wrote:
> 
>> I need to validate two fields on my webpage, two dates, and I need to
>> check if one date is greater than the
>> other. Is this possible? Have I access to the other fields from within
>> my validate method or is there another
>> way of doing this (or do I have to check this in my save method)?
>>
>>
>> Regards,
>>
>> BTJ
>>
>>  
>>
> 

-- 
Don't answer to From: address!
Mail to this account are droped if not recieved via mailinglist.
To contact me direct create the mail address by
concatenating my forename to my senders domain.

Re: How to write a customized valdation, that validate by comparing one field to another_

Posted by Le Van <lv...@it.fts-vn.com>.
You could do it using validator. Read "*JavaServer Faces" of Hans Bergsten.*
Bjørn T Johansen wrote:

>I need to validate two fields on my webpage, two dates, and I need to check if one date is greater than the
>other. Is this possible? Have I access to the other fields from within my validate method or is there another
>way of doing this (or do I have to check this in my save method)?
>
>
>Regards,
>
>BTJ
>
>  
>