【问题标题】:javax.el.ELException: Function 'rich:component' not foundjavax.el.E​​LException:找不到函数“丰富:组件”
【发布时间】:2011-08-19 20:22:02
【问题描述】:

我在 backing 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"/>

如何解决上述错误。

【问题讨论】:

  • createValueExpression(?, ?) 是做什么的?我预计这是由于缺乏上下文。

标签: jsf components richfaces richfaces-modal


【解决方案1】:

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

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)

【讨论】:

    猜你喜欢
    • 2014-08-14
    • 2012-03-13
    • 2016-05-29
    • 2011-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-29
    相关资源
    最近更新 更多