jsfcomponentsrichfacesrichfaces-modal

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


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", createValueExpression("#{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.


Solution

  • 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)