fra*_*kok 2 datatable binding primefaces jsf-2
我有关于primefaces数据表组件的问题.我想将一个DataTable变量绑定到p:dataTable,以便我能够从支持bean以编程方式操作第一行,rowsPerPageTemplate等.但我陷入困境并不断获取java.lang.String无法转换为javax.faces.component.UIComponent.
这是我的p:dataTable声明.
<p:dataTable id="dtProductCategoryList" value="#{saProductCategoryController.saproductcategories}" rowsPerPageTemplate="#{appConfig.rowsPerPageTemplate}"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
currentPageReportTemplate="{currentPage} #{bundle.DataTablePageSeparator} {totalPages}"
paginatorAlwaysVisible="false" var="item" paginator="true" rows="#{appConfig.rowsPerPageDefault}"
binding="saProductCategoryController.dtProductCategory">
Run Code Online (Sandbox Code Playgroud)
这是我的ViewScoped支持bean.
private DataTable dtProductCategory;
/** Creates a new instance of saProductCategoryController */
public SaProductCategoryController() {
}
@PostConstruct
public void Init() {
try {
dtProductCategory = new DataTable();
//dtProductCategory.
saproductcategories = saProductCategoryFacade.selectAll();
LogController.log.info("Creating postconstruct for saProductCategoryController");
} catch (Exception ex) {
LogController.log.fatal(ex.toString());
}
}
Run Code Online (Sandbox Code Playgroud)
可能是什么问题呢?似乎DataTable变量被误认为是String?
感谢您的所有帮助.谢谢.
java.lang.String无法强制转换为javax.faces.component.UIComponent.
该binding属性必须引用UIComponent,而不是普通的香草String.事实上,你忘记了#{}属性值,这将使它被视为普通的香草String.
相应修复:
binding="#{saProductCategoryController.dtProductCategory}"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16761 次 |
| 最近记录: |