Karina
Karina

Reputation: 197

Primefaces Slider does not call setter

I have a primefaces (version 3.4.2) slider and an inputText for output value of the slider value. The problem is that a change of the slider update the displayed value of the inputText, but the setter bind to the inputText is not called.

Here is my slider:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:a4j="http://richfaces.org/a4j">

    <h:head>
        <title>Zinsrechner</title>
    </h:head>

    <h:body>

        <h:form>
            <h:panelGrid columns="1" style="margin-bottom:10px">
                <p:inputText id="x" value="#{zinsrechner.monatlicherBeitrag}" />
                <p:slider minValue="0" maxValue="150" for="x" />
            </h:panelGrid>
        </h:form>

    </h:body>

</html>

And this is my Setter, which is NOT called:

public void setMonatlicherBeitrag( Double beitrag ) {
    monatlicherBeitrag = beitrag;
}

The Getter IS called:

public Double getMonatlicherBeitrag() {
    return GuiParameter.getSpareinlageProMonat();
} 

Upvotes: 7

Views: 5680

Answers (2)

Julio
Julio

Reputation: 446

I was facing the same problem, but in my case the thing was that I was setting the <p:inputNumber .../> label as read only. I removed that attribute and everything worked.

Upvotes: 3

Patrick Trautmann
Patrick Trautmann

Reputation: 409

Adding a <p:ajax> inside your Slider will to the trick.

Example:

<p:slider minValue="0" maxValue="150" for="x">
    <p:ajax event="slideEnd" process="x" />
</p:slider>

Upvotes: 11

Related Questions