我在使用带有多重选择(复选框)的primefaces数据表时遇到问题,下面的复合主键是我的xhtml
<p:dataTable id="cars" var="car" value="#{setujutolakanpencairan.listmktksppencairan0}"
rowKey="#{car.mktksppencairan0PK}"
selection="#{setujutolakanpencairan.mktksppencairan0s}" >
<p:ajax event="rowSelectCheckbox" process="@this"/>
<p:column selectionMode="multiple" style="width:2%" />
<f:facet name="header">
Click "View" button after selecting multiple to see details
</f:facet>
<p:column headerText="Color">
#{car.vcKeterangan}
</p:column>
<f:facet name="footer">
<p:commandButton value="View" icon="ui-icon-search"
update=":form:display" oncomplete="carDialog.show()" actionListener="#{setujutolakanpencairan.outprint()}"/>
</f:facet>
</p:dataTable>
下面是我的背豆
private List<Mktksppencairan0> listmktksppencairan0;
private Mktksppencairan0[] mktksppencairan0s;
下面是我的吸气剂二传手
public Mktksppencairan0[] getMktksppencairan0s() {
if (mktksppencairan0s != null) {
for (Object asdf : mktksppencairan0s) {
System.out.println("mktksppencairan0s mktksppencairan0s mktksppencairan0smktksppencairan0s =====" + asdf);
}
}
return mktksppencairan0s;
}
public void setMktksppencairan0s(Mktksppencairan0[] mktksppencairan0s) {
this.mktksppencairan0s = mktksppencairan0s;
}
下面是显示数据的列表
public List<Mktksppencairan0> getListmktksppencairan0() {
TypedQuery<Mktksppencairan0> query = em.createNamedQuery("Mktksppencairan0.findBybulantahun", Mktksppencairan0.class);
query.setParameter(
"iTahun", mktkontrol.getTahun());
query.setParameter(
"iBulan", mktkontrol.getBulan());
List<Mktksppencairan0> results = query.getResultList();
return results;
}
public void setListmktksppencairan0(List<Mktksppencairan0> listmktksppencairan0) {
this.listmktksppencairan0 = listmktksppencairan0;
}
这是我用来调试值的操作
public void outprint() {
System.out.println("asdfasdf ===" + mktksppencairan0s.toString().length());
System.out.println("asdfasdf ===" + mktksppencairan0s.toString());
System.out.println("asdfasdf ===" + mktksppencairan0s);
for (Mktksppencairan0 asdf : mktksppencairan0s) {
System.out.println("mktksppencairan0s mktksppencairan0s mktksppencairan0smktksppencairan0s =====" + asdf.toString().length());
}
}
当我使用 netbeans 调试器进行调试时,它是结果 [] 或 0 当我 System.out 时它结果
INFO: asdfasdf ===[Lcom.infion.web.biaya_marketing.entity.Mktksppencairan0;@a20a9b
INFO: asdfasdf ===64
INFO: asdfasdf ===[Lcom.infion.web.biaya_marketing.entity.Mktksppencairan0;@1f5db6
INFO: asdfasdf ===[Lcom.infion.web.biaya_marketing.entity.Mktksppencairan0;@1f5db6
仅供参考,我使用的是 netbeans 7.3、glassfish 3.1.2、primefaces 3.5 * 我使用的实体是由 netbean 生成的,所以有两类实体 Mktksppencairan0PK 和 Mktksppencairan0 ,其中 Mktksppencairan0 已嵌入 Mktksppencairan0PK 感谢您的帮助
注意:我尝试使用非复合主键(单个主键)及其工作,但是当我尝试使用另一个复合主键时它不起作用