2017-01-05 33 views
1

我有這個表:用PrimeFaces onClick提交參數?

.divTable{ 
 
\t display: table; 
 
\t width: 50%; 
 
     padding-top: 100px; 
 
     padding-left: 100px; 
 
     margin-left: auto; 
 
     margin-right: auto; 
 
} 
 
.divTableRow { 
 
\t display: table-row; 
 
} 
 
.divTableHeading { 
 
\t background-color: #EEE; 
 
\t display: table-header-group; 
 
} 
 
.divTableCell, .divTableHead { 
 
\t border: 1px solid #999999; 
 
\t display: table-cell; 
 
\t padding: 3px 10px; 
 
     background-color: #ffffff; 
 
     width: 50%; 
 
} 
 
.divTableHeading { 
 
\t background-color: #EEE; 
 
\t display: table-header-group; 
 
\t font-weight: bold; 
 
     width: 100%; 
 
} 
 
.divTableFoot { 
 
\t background-color: #EEE; 
 
\t display: table-footer-group; 
 
\t font-weight: bold; 
 
} 
 
.divTableBody { 
 
\t display: table-row-group; 
 
}
<div class="divTable"> 
 
    <div class="divTableBody"> 
 
    <ui:repeat var="customerInList" value="#{customerListController.resultMap.currentPositionResultList}">           <div class="divTableRow"> 
 
    <div class="divTableCell">#{customerInList.lastName} #{customerInList.firstName}</div> 
 
     <div class="divTableCell">#{customerInList.postalStreet} 
 
     <p:commandButton id="editCustomerButton" label="+" iconPos="center" onclick="PF('editCustomerDialog').show()"/> 
 
     <br/>#{customerInList.postalCode} #{customerInList.postalCity} 
 
     <br/>#{customerInList.phoneNumber} 
 
     <br/>#{customerInList.email} 
 
           
 
     </div> 
 
    </div> 
 
    </ui:repeat> 
 
</div> 
 
</div> 
 
    <p:dialog widgetVar="editCustomerDialog"> 
 
        
 
    </p:dialog>

而且這種方法

public void parseParameter(int ID){ 
    this.ID = ID; 
} 

所以這纔是我的問題。 正如你可能已經看到我正在嘗試創建一個Popup來顯示有關客戶的更多細節。我的想法是,我可以從一個Invisible div或類似的東西解析客戶的Id,這樣我就可以用這個ID從我的數據庫中獲取剩餘的數據,但這對我來說不起作用。

有沒有其他方法可以做到這一點?

+0

你正在使用什麼教程?題外:你爲什麼不用桌子?因爲有人告訴你他們「不好」?你使用divs,然後告訴它們像表頭/行/單元格一樣。那是在我的(不那麼)謙卑的意見中更糟。 – Kukeltje

回答

1

您可以使用f:setPropertyActionListener從您p:commandButton設定值,你的bean,然後使用action事件的按鈕來得到你的數據庫的任何額外的數據,你可以展示你對oncomplete事件,而不是onclick對話框所以它得到在你的bean方法之後執行。

<p:commandButton id="editCustomerButton" label="+" iconPos="center" action="#{customerListController.methodToGetYourRemainingData}" oncomplete="PF('editCustomerDialog').show()"> 
    <f:setPropertyActionListener target="#{customerListController.ID}" value="#{customerInList.ID}" /> 
</p:commandButton> 
+0

謝謝你幫助我。 – Frekell