javax.el.ELException:未找到函数'rich:component'



我正在后台bean中创建模型。

我的java代码行是这样的

UIColumn column = new HtmlColumn();
    dynamicDataTable.getChildren().add(column);
    UIAjaxCommandLink editLink = new HtmlAjaxCommandLink();
    editLink.setId("edit");
    HtmlGraphicImage img = new HtmlGraphicImage();
    img.setUrl("../images/edit.gif");
    editLink.getChildren().add(img);
    editLink.setActionExpression(createActionExpression("#{myBean.editRow}", String.class));
    editLink.setAjaxSingle(true);
    editLink.setValueExpression("onComplete", createValueExpression("#{rich:component('editPanel')}.show()", RichFunction.class));
    editLink.setValueExpression("reRender", createValueExpression("editPanel", String.class));
    column.getChildren().add(editLink);

得到一个错误。在xhtml页面中也是如此。

<a4j:commandButton value="Edit" ajaxSingle="true" 
    oncomplete="#{rich:component('editPanel')}.show()" 
    actionListener="#{myBean.addActionListener}" reRender="editPanel"/>

我得到了解决方案,我输入以下代码

editLink.setOncomplete("Richfaces.showModalPanel('editPanel');");

代替

editLink.setValueExpression("onComplete", createValueExpression("#{rich:component('editPanel')}.show()", RichFunction.class))

McDowell:现在来看看createValueExpression:

private ValueExpression createValueExpression(String valueExpression, Class<?> valueType) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    return facesContext.getApplication().getExpressionFactory().createValueExpression(
        facesContext.getELContext(), valueExpression, valueType);
}
private MethodExpression createActionExpression(String actionExpression, Class<?> returnType) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    return facesContext.getApplication().getExpressionFactory().createMethodExpression(
        facesContext.getELContext(), actionExpression, returnType, new Class[0]);
}

我使用这个例子创建了这个包含动态列的表。

http://balusc.blogspot.com/2006/06/using-datatables.html PopulateDynamicDatatable

感谢Bauke Luitsen Scholtz (BalusC)

相关内容

  • 没有找到相关文章

最新更新