如果未在 JDK1.5 中设置 ID,则不会从可编辑数据表中更新绑定值
如果未在 JDK 1.5 中设置 ID,则不会从可编辑数据表中更新绑定值。但在 JDK 1.6 中无需设置 ID 也同样可以工作。 有谁知道为什么?感谢
代码,Bean部分
public void setDataTable(HtmlDataTable dataTable) {
this.dataTable = dataTable;
}
public HtmlDataTable getDataTable() {
if (dataTable == null)
setEditableDataTable();
return dataTable;
}
private void setEditableDataTable() {
dataTable = new HtmlDataTable();
dataTable.setValueBinding("value",
createValuebinding("#{testBean.stringList}"));
dataTable.setVar("items");
for (int i = 0; i < getDatastable().get(i).size(); i++) {
UIColumn column = new UIColumn();
dataTable.getChildren().add(column);
HtmlOutputText header = new HtmlOutputText();
header.setValue("Header "+i);
column.setHeader(header);
HtmlInputText input = new HtmlInputText();
input.setValueBinding("value", createValuebinding("#{items[" + i
+ "]}"));
column.getChildren().add(input);
}
}
private ValueBinding createValuebinding(String valueExpression) {
return FacesContext.getCurrentInstance().getApplication()
.createValueBinding(valueExpression);
}
JSP部分
<h:dataTable binding="#{testBean.dataTable}" >
</h:dataTable>
解决方案
Give id for the datatable
Bound values are not getting updated from editable data table without setting ID in JDK 1.5. But the same does work without setting ID in JDK 1.6.
Does anyone know why? Thanks
Code, Bean part
public void setDataTable(HtmlDataTable dataTable) {
this.dataTable = dataTable;
}
public HtmlDataTable getDataTable() {
if (dataTable == null)
setEditableDataTable();
return dataTable;
}
private void setEditableDataTable() {
dataTable = new HtmlDataTable();
dataTable.setValueBinding("value",
createValuebinding("#{testBean.stringList}"));
dataTable.setVar("items");
for (int i = 0; i < getDatastable().get(i).size(); i++) {
UIColumn column = new UIColumn();
dataTable.getChildren().add(column);
HtmlOutputText header = new HtmlOutputText();
header.setValue("Header "+i);
column.setHeader(header);
HtmlInputText input = new HtmlInputText();
input.setValueBinding("value", createValuebinding("#{items[" + i
+ "]}"));
column.getChildren().add(input);
}
}
private ValueBinding createValuebinding(String valueExpression) {
return FacesContext.getCurrentInstance().getApplication()
.createValueBinding(valueExpression);
}
JSP part
<h:dataTable binding="#{testBean.dataTable}" >
</h:dataTable>
Solution
Give id for the datatable
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论