The surface slider doesn't setter

I have a slider (version 3.4.2) and inputText for the output value of the slider value. The problem is that changing the slider updates the displayed value of inputText, but the binding of the binding to 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; } 

Getter IS called:

 public Double getMonatlicherBeitrag() { return GuiParameter.getSpareinlageProMonat(); } 
+4
source share
2 answers

Adding <p:ajax> inside your slider will do the trick.

Example:

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

I had the same problem, but in my case, the fact is that I set the label <p:inputNumber .../> as read-only. I removed this attribute and it worked.

+1
source

Source: https://habr.com/ru/post/1447721/


All Articles