2012-11-22 58 views
4

我有一個primefaces(版本3.4.2)滑塊和一個inputText輸出值的滑塊值。 問題是滑塊更改更新了inputText的顯示值,但setter綁定到inputText未被調用。Primefaces滑塊不調用setter

這裏是我的滑塊:

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

這是我的二傳手,這不叫:

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

吸氣劑稱爲:

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

你的bean是如何標註的? –

+0

With @ManagedBean(name =「zinsrechner」) @SessionScoped – Karina

+0

您是否在任何地方提交表單? – stg

回答

9

添加<p:ajax>內你的滑塊將訣竅。

例子:

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

謝謝,現在它工作。 – Karina

+0

謝謝!在我的情況下,我不得不使用'process =「@ form」' – Pablo

1

我面臨同樣的問題,但在我的情況下,事情是,我設置<p:inputNumber .../>標籤爲只讀。我刪除了該屬性,一切正常。

+0

是的,當只讀屬性爲true時,不會發送從滑塊獲取的值。 – AngelAvila