Search code examples
jsf-2richfaces

Why does rich:inputNumberSlider does not update backing bean (@Managed Bean)


The inputNumberSlider of Richfaces fails in my case to immediately update the backing bean. The setter method is never invoked. I'm right in saying, that backing bean field should should be updated on change?

<rich:inputNumberSlider 
id="severityLevel" 
value="#{pubController.severityLevel}"
minValue="1" 
maxValue="3" 
maxlength="1" />

I did set a breakpoint in the setter method, but it never rises. I must say, it works properly for all the h:inputText tags.


Solution

  • The setSecurityLevel setter will never be invoked till you submit the form where your rich:inputNumberSlider is contained.

    Alternatively, you can set the value whenever the inputNumberSlider is changed, adding an ajax per event processing, which will execute your component (I don't use richfaces, but that would be the desired format):

    <h:form>
        <rich:inputNumberSlider id="severityLevel" value="#{pubController.severityLevel}"
            minValue="1" maxValue="3" maxlength="1" >
            <a4j:ajax event="change" execute="@this" />
        </rich:inputNumberSlider>
    </h:form>
    

    Generally, that kind of behaviour is unrequired unless you want to perform some kind of validation while user is changing the input value (it also could be useful to render dependent components). In most of the cases the validation is performed over all the components once you post the whole form.