Use a hidden field on the form.  Associate a custom validator with the
hidden field.  When the application is submitted, the custom validator
compares both text field and combo box and throws a validation error
only if both are null.

Regards,

Fintan

-----Original Message-----
From: Srikanth Madarapu [mailto:[EMAIL PROTECTED] 
Sent: 22 April 2005 16:07
To: MyFaces Discussion; Matthias Wessendorf
Subject: RE: Cross component validation question


At first look I did not understand why this new tag was posted in this
thread.

 Because, the need to get another component's could arise in the
following scenario too... ( I had this scenario ).

 On a form I have few input fields. One of them is school name. The
school name can be input by choosing from a drop down or by entering in
a text field, this piece of information is required, but I cannot set
the required attribute to true because the user could choose or enter in
the text field. So in my validator of the drop down I get the submitted
value of the text field and if both are null throw a validator
exception.

 I don't know if there is a better way of handling this.

-Srikanth

-----Original Message-----
From: Matthias Wessendorf [mailto:[EMAIL PROTECTED]
Sent: Friday, April 22, 2005 10:50 AM
To: MyFaces Discussion
Subject: Re: Cross component validation question


I have created an equal validator for MyFaces (<x:validateEqual/>)

<h:inputText id="passwd1" .../>
<h:inputText id="passwd2" ...>
  <x:validateEqual for="passwd1"/>
</h:inputText>

but it is limited to JSF spec 1.1 ...

in other words, you can't place it before passwd1

SRC can be found in CVS

HTH,
Matthias

On 4/22/05, Srikanth Madarapu <[EMAIL PROTECTED]> wrote:
> If you know the id of component B, you could get using... (you already

> have access to component A)
> 
> componentA.findComponent( "id of component B").getSubmittedValue()
> 
> -Srikanth
> 
> -----Original Message-----
> From: Robert Breidecker [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 21, 2005 2:42 PM
> To: MyFaces Discussion
> Subject: Cross component validation question
> 
> This is something I think I should be able to figure
> out, but haven't been able to yet.
> 
> Does anyone know how to get the value of another
> component that was entered in the form when validating
> for another component.
> 
> Let's say I have Component A and Component B.  A has a
> value of 1 and B a value of 2.  On the screen I enter
> 11 for A and 12 for B.  In my validator for B I want
> to see the value of 11 for A.  However, I get the
> value of 1 for A which is the value stored in the
> backing bean.  How can I get to the value of 11?
> 
> Thanks,
> Rob Breidecker
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com
> 


-- 
Matthias Wessendorf


* ** *** ** * ** *** ** * ** *** ** * 
This email and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they 
are addressed. 
Any views or opinions presented are solely those of the author, and do not 
necessarily 
represent those of ESB. 
If you have received this email in error please notify the sender. 
 
Although ESB scans e-mail and attachments for viruses, it does not guarantee 
that either are virus-free and accepts no liability for any damage sustained 
as a result of viruses. 
 
* ** *** ** * ** *** ** * ** *** ** *

Reply via email to