p:即使列表不为空,也不会填充dataTable

时间:2016-09-01 16:45:33

标签: primefaces

我一直在使用primefaces并且我创建了一个对话框,该对话框应该弹出一个dataTable但它仍然不会返回找到的记录,即使列表已被填充。

请参阅以下代码:

Java Bean:

    public List<accountDetails> accountDetails(String refNo, DatabaseHandler dbase)
{

    try (Connection con = dbase.getDBConnection(DatabaseTypes.TRANSACTION_DATABASE))
    {
        String sql = null;

                //lookup id number or accountNumber   
                if(refNo.substring(0, 5).length() == 13){
            sql =
                "SELECT recID,AccountNo,Balance FROM tblPay@SABCRegistrations WHERE IDNumber ="
                    + refNo.substring(5);
                }else{
            sql = "SELECT recID,AccountNo,Balance FROM tblPay@SABCRegistrations"; // WHERE AccountNo ="
            // + refNo.substring(5);
                }


        ResultSet result = DatabaseHandler.executeQuery(con, sql);
        accList = new ArrayList<>();
        while (result.next())
        {
            accountDetails t = new accountDetails();
                            t.setRecID(result.getString("recID"));
            t.setAccountNo(result.getString("AccountNo"));
            t.setAmount(result.getString("Balance"));
            accList.add(t);

        }
        result.close();
                    System.out.println(accList);
        openDialog();
    }
    catch (Exception e)
    {
        FacesContext.getCurrentInstance().addMessage(
            null,
            new FacesMessage(FacesMessage.SEVERITY_ERROR, "An error occurred.", e.getMessage()));
    }

            return accList;

}

public void openDialog()
{
    if (accList.get(0).getAccountNo() != null || !accList.get(0).getAccountNo().isEmpty())
    {
        RequestContext.getCurrentInstance().execute("PF('payDialog').show()");
    }
}

xHTML页面:

     <p:dialog header="Would you like to pay now?" widgetVar="payDialog" resizable="false"  
                      width="1000" id="dialogStatus">  
                 <h:form id="dial">
                <h:panelGrid id="displayStatus" columns="1" cellpadding="4">  


                     <p:dataTable id="fTable" value="#{authBean.accList}" rows="10" 
                                         var="t" widgetVar="feesTable" rowKey="#{t.recID}" 
                                         selectionMode="single"
                                         style="font-size:12px"
                                         resizableColumns="true"
                                         selection="#{authBean.selectedAccount}"
                                         >

                                <p:column headerText="Account No:" style="text-align: left; width: 200px">
                                    <f:facet name="Header">
                                        <h:outputText value="Account No:"/>
                                    </f:facet>
                                    <h:outputText value="#{t.accountNo}"/>
                                </p:column>

                                <p:column headerText="Amount:" style="text-align: left; width: 250px">
                                    <f:facet name="Header">
                                        <h:outputText value="Amount:"/>
                                    </f:facet>
                                    <h:outputText value="#{t.amount}"/>
                                </p:column>
                         </p:dataTable>


                    <p:commandButton id="btnChangeStatus" value="Pay Now" action="#{authBean.logout}" 
                                     oncomplete="payDialog.hide()"
                                     ajax="true"/>  

                    <p:commandButton id="close" value="Cancel" action="#{authBean.endDialog}"/>

                </h:panelGrid> 
             </h:form>
            </p:dialog>        

0 个答案:

没有答案