2014-10-31 26 views
0

我有一個表單。在表單中,我有一個數據表。下面你可以找到我的代碼:p:commandButton設置其類型爲提交時不起作用

<p:column headerText="Extra request"> 
    <p:commandButton id="requestDetailsButton" value="details" type="button" 
        update="detailPanel" 
        action="#{enbBean.sendEnbDetailsRequest(selectedEnbData.eNbAddress)}" 
        onclick="enbDetailsDialog.show()"> 

     <f:setPropertyActionListener id="rowSelected" value="a" target="#{enbBean.selectedEnbData}" /> 
    </p:commandButton> 
</p:column> 

的問題是,我需要與type=submit設置的命令按鈕。但是當我這樣做的時候,整個頁面就會崩潰。爲什麼它打破了,我怎麼能克服這個問題?

+0

你可以試試如果您希望在操作完成後顯示對話框,請刪除type =「button」並將「onclick」更改爲「oncomplete」。 – Multisync 2014-10-31 14:03:06

+0

如果我刪除type =「button」,那麼整個頁面都會中斷並且不顯示任何內容。這是我的問題... – 2014-10-31 14:05:47

+0

點擊按鈕後發生了什麼?你的行爲可能有問題嗎?也正如我所知f:setPropertyActionListener沒有id屬性 – Multisync 2014-10-31 14:08:18

回答

1

你可以試試這個:

<p:commandButton id="requestDetailsButton" value="details" 
       update="detailPanel" 
       action="#{enbBean.sendEnbDetailsRequest}" 
       oncomplete="enbDetailsDialog.show()"> 
    <f:setPropertyActionListener value="a" target="#{enbBean.selectedEnbData}" /> 
</p:commandButton> 

public void sendEnbDetailsRequest() { 
    ... 
} 

setPropertyActionListener將設置#{} enbBean.selectedEnbData動作叫做

之前或者,你可以嘗試這樣的事:

<p:commandButton id="requestDetailsButton" value="details" 
       update="detailPanel" 
       actionListener="#{enbBean.sendEnbDetailsRequest}" 
       oncomplete="enbDetailsDialog.show()"> 
    <f:attribute name="selectedEnbData" value="a"/> 
</p:commandButton> 

public void sendEnbDetailsRequest(ActionEvent ae) { 
    String selectedEnbData = (String)ae.getComponent().getAttributes().get("selectedEnbData"); 
    ... 
}