You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Anton Gavazuk <an...@gmail.com> on 2009/06/02 14:19:45 UTC
Re: obtain the component value
Hi,
I suggest to look on children of parent component:
toValidate.getParent().getChildren();
//and find amoint the children needed value - for example by -
if(uiComponent.getId().equals("radioValue")){
//and cast the Radibutton component to related JSF class - I dont remember
the RadioButton class.
((HtmlRadioButton)uiComponent).getValue();
}
2009/5/28 mitroiasi <mi...@yahoo.com>
>
>
> Hi,
>
> I want to implement a validator. All works fine, the only problem I have is
> the fact that I need the value of another component (radio button). How can
> I obtain the other value?
>
> the code is this:
> public void validateInputValue(FacesContext context,
> UIComponent toValidate,
> Object value) {
> BigDecimal inputValue = (BigDecimal) value;
> if (inputValue .compareTo(BigDecimal("1000")) > 0) {
> ((UIInput)toValidate).setValid(false);
>
> FacesMessage message = new FacesMessage("error");
> context.addMessage(toValidate.getClientId(context),
> message);
> }
> }
>
> validator="#{enterprise.validateInputValue}"
>
> The other component is:
> <h:selectOneRadio id="radioValue"
> value="#{enterpirse.radioValue}">
> <f:selectItem itemValue="true" itemLabel="kWh" />
> <f:selectItem itemValue="false" itemLabel="MWh" />
> </h:selectOneRadio>
>
> In the method "validateInputValue" from the backing bean I want to know
> also
> the boolean value radioValue.
> --
> View this message in context:
> http://www.nabble.com/obtain-the-component-value-tp23759909p23759909.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>