我正在使用 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>
那么问题到底是什么?