对话框中的primefaces数据表不会在第一次显示

时间:2012-11-09 11:00:42

标签: ajax jsf primefaces

我正在使用primefaces-3.4并且有一个对话框(详细信息页面),以显示母版页上数据表中所选项目的详细信息。我的bean是@ViewScoped,在actionListener方法我正在加载详细信息。显示母版页时,首先单击p:commandButton,它不会填充对话框,在第二次单击时它会正确显示。我已经使用Chrome开发人员工具进行了检查,并且没有看到任何异常,只是所选项目的详细信息没有“绑定”到UI。

这是我的bean代码和xhtml

@PostConstruct
public void init() {
    // load credits if there is an account selected...
    if (mainBean.getSelectedAccount() != null) {

        ArrayList<Credit> cs = loadCredits(mainBean.getSelectedAccount());
        setCredits(cs);
        mainBean.getSelectedAccount().setCredits(cs);
    }
    if (this.selectedCredit != null) {
        ArrayList<Installation> installations = loadInstallations(selectedCredit);
        selectedCredit.setInstallations(installations);
        setPaymentAmount(Float.parseFloat(installations.get(installations.size()-1).getAmount()));
    }
}
....
//actionListener to select
public String select() {
    if (selectedCredit != null) {
        ArrayList<Installation> installations = loadInstallations(selectedCredit);
        selectedCredit.setInstallations(installations);
    }
    return null;
}

这是我的xhtml中的片段

<p:dataTable var="credit" selectionMode="single"
                        emptyMessage="Kayıt Bulunamadı..."
                        selection="#{accountBean.selectedCredit}" rowKey="#{credit.id}"
                        value="#{accountBean.credits}" id="credit_table" paginator="true"
                        paginatorAlwaysVisible="false" rows="10">
                        <f:facet name="header">
                            <small>İlgili krediyi seçtikten sonra "Detay" butonuna
                                tıklayınız..</small>
                        </f:facet>
                        <p:column>
                            <h:outputText headerText="Kredi ID" value="#{credit.id}" />
                        </p:column>
                        <p:column headerText="Kredi Adı">
                            <h:outputText value="#{credit.name}" />
                        </p:column>
                        <p:column headerText="Tutarı">
                            <h:outputText value="#{credit.total}" />
                        </p:column>

                        <f:facet name="footer">
                            <p:toolbar>
                                <p:toolbarGroup align="left">
                                    <p:commandButton actionListener="#{accountBean.select}"
                                        icon="ui-icon-search"
                                        update=":productdetailform:product_detail"
                                        oncomplete="kredidetail.show();" value="Detay">
                                        <f:ajax render=":productdetailform:product_detail" />
                                    </p:commandButton>
....
<h:form id="productdetailform">
            <p:dialog id="product_detail"
                header="#{accountBean.selectedCredit.name}" widgetVar="kredidetail"
                modal="true" height="700" width="850">
                <div class="row">
                    <div class="twelve columns">
                        <ul class="block-grid three-up">
                            <li><b>Kredi Hesap Adı: </b> <h:inputText readonly="true"
                                    value="#{accountBean.selectedCredit.name}" /></li>
                            <li><b>Kredi Tutarı: </b> <h:inputText readonly="true"
                                    value="#{accountBean.selectedCredit.total}" /></li>
                            <li><b>Veriliş Tarihi: </b> <p:calendar readonly="true"
                                    pattern="dd.MM.yyyy" readonlyInput="true" id="loan_date"
                                    value="#{accountBean.selectedCredit.loanDate}" /></li>
                            <li><b>Ödenen: </b> <h:inputText readonly="true"
                                    value="#{accountBean.selectedCredit.paid}" /></li>
                            <li><b>Kalan: </b> <h:inputText readonly="true"
                                    value="#{accountBean.selectedCredit.remaining}" /></li>
                            <li><b>Durumu: </b> <h:outputText value="AKTİF" /></li>

                        </ul>
                    </div>
                </div>
                <div class="row">
                    <div class="twelve columns">
                        <p:dataTable var="ins" emptyMessage="Kayıt Bulunamadı..."
                            value="#{accountBean.selectedCredit.installations}"
                            id="credit_details_table">
                            <p:column headerText="Taksit No">
                                <h:outputText value="#{ins.installationNo}" />
                            </p:column>
                            <p:column headerText="Vadesi">
                                <h:outputText value="#{ins.paymentDue}">
                                    <f:convertDateTime pattern="dd.MM.yyyy" />
                                </h:outputText>
                            </p:column>
                            <p:column headerText="Taksit Tutarı">
                                <h:outputText value="#{ins.amount}" />
                            </p:column>
                            <p:column headerText="Taksit Tutarı">
                                <h:outputText value="#{ins.paidAmount}" />
                            </p:column>
                            <p:column headerText="Ödeme Durumu">
                                <h:outputText value="#{ins.status}" />
                            </p:column>
                            <p:column headerText="Ödeme Tarihi">
                                <h:outputText value="#{ins.actualDate}" />
                            </p:column>
                        </p:dataTable>
                    </div>
                </div>
            </p:dialog>
        </h:form>

那么究竟是什么问题?

1 个答案:

答案 0 :(得分:0)

AFAIK,actionListener方法必须具有签名:public void actionListener(ActionEvent event)。您可以尝试使用action代替actionListener

另外,您是否有数据表的封闭表格?使用多个表单时,JSF中存在一些错误。尝试更新整个表单而不是仅对话:update=":productdetailform"