2012-08-14 51 views
1

我需要在我的模型中設置一些值並將頁面導航到另一個值,但按鈕單擊時(頁面導航和方法都不觸發)沒有任何反應....我的代碼在旋轉木馬但裏面的旋轉木馬它不工作(沒有頁面導航)導航不適用於primefaces旋轉木馬

<p:carousel value="#{catalog.getServices()}" var="s" rows="1"> 
    <h:outputLabel for="id" value="Service ID " /> 
    <h:outputText id="id" value="#{s.id}" /> 
    <br></br> 
    <h:outputLabel for="name" value="Service Name" /> 
    <h:outputText id="name" value="#{s.name}" /> 
    <br /> 
    <h:commandLink action="detail"> 
    <f:setPropertyActionListener value="#{s}" target="#{sh.currentService}" /> 
    <h:commandButton value="getService" style="float:right;" /> 
    </h:commandLink> 
</p:carousel> 

我的導航完美的作品這個旋轉木馬

<h:commandLink action="detail"> 
    <f:setPropertyActionListener value="#{s}" target="#{sh.currentService}" /> 
    <h:commandButton value="getService" style="float:right;" /> 
</h:commandLink> 

外上面的代碼可以讓我的網頁瀏覽和方法,我想觸發也工作正常

回答

1

您應該避免在h:commandLink以內嵌套h:commandButton

只需使用h:commandButton這樣:

<h:commandButton value="getService" action="#{yourBean.yourActionMethod}"> 
    <f:setPropertyActionListener .../> 
</h:commandButton> 

並在您的支持bean返回導航目標從操作方法的結果:

public String yourActionMethod() { 
    // do your stuff here 
    return "detail"; 
} 
+0

這也不是爲我工作:( – 2012-08-14 12:59:13

+0

即使這不工作....當我有這個命令按鈕外旋轉木馬其工作正常.... – 2012-08-14 13:02:35

+1

你應該檢查,如果請求是從客戶端觸發(使用瀏覽器開發工具)如果執行backing bean方法,你也可以嘗試一個完整的請求,而不是ajax請求(在'p:commandButton'中設置'ajax =「false」) – 2012-08-15 06:13:02