Hi Joe,

If you bind each component in the group to a backing bean, then you
attach a custom converter to the last control of the group that appears
on the page (e.g. input field).


public class BackingBean {
private SelectOneRadio radio;
private UIInput radioInput;
...
public void validateRadioText(FacesContext context, UIComponent
component, Object value) {
   Boolean buttonClicked = ((Boolean)
radio.getLocalValue()).booleanValue();
   String radioText = (String)value;      // 1

   if (buttonClicked) {
      if(!validText(radioText)) {
         FacesMessage message = ...;
         throw new ValidatorException(message);
      }
   }
}

Private validText(String textToValidate) {
   // validate the text here
}
...
}

NB - The last component will not have its local value set yet (see //1)

In the JSF page set the validator of the last component to this
validator method
<t:inputText value=#{...} binding=#{bb.radioInput}
validator=#{bb.validateRadioText}>

Where bb is set as a managed Backing Bean in faces-config.

Alternatively you could use a hidden field which is the last field on
the page :
<h:inputHidden validator="#{bb.validateRadioText}" value="needed"/>

In this case you get the value for radioText (see //1), similarly to how
it was gotten for buttonClicked, as the local value has been set.

Otherwise you can define your own component similarly to above, if you
will need this functionality in more than one page.

Regards,

Fintan


-----Original Message-----
From: Joe ersinghaus [mailto:[EMAIL PROTECTED] 
Sent: 10 August 2006 00:35
To: MyFaces Discussion
Subject: many components to one (or more) validation?


Hello,

Is it possible to have more than one component validated as a group? For

example:  let's say I've have a radio button that when activated, text 
must be entered/validated in that radio button's associated input field?

In other words, only when the radio button is selected, should the input

filed be validated.


Thanks,
Joe


* ** *** ** * ** *** ** * ** *** ** * 
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