开发者

javax.el.ELException: Function 'rich:component' not found

开发者 https://www.devze.com 2023-03-29 03:28 出处:网络
I am creating the model in backing bean. My java lines of code are like this UIColumn column = new HtmlColumn();

I am creating the model in backing bean.

My java lines of code are like this

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", createValueExpr开发者_如何学JAVAession("#{rich:component('editPanel')}.show()", RichFunction.class));
    editLink.setValueExpression("reRender", createValueExpression("editPanel", String.class));
    column.getChildren().add(editLink);

I get an error. The same works for in the xhtml page.

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

How can I resolve the above error.


I got the solution, I put the following code

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

instead of

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

McDowell : Now coming to the 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]);
}

I used the example from this to create this table with dynamic columns.

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

Thanks Bauke Luitsen Scholtz (BalusC)

0

精彩评论

暂无评论...
验证码 换一张
取 消