2011-08-19 10 views
0

Я создаю модель в бэкэнде.javax.el.ELException: Функция «rich: component» not found

Мои ява строки кода, как этот

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"/> 

Как устранить вышеуказанную ошибку.

+0

Что 'createValueExpression (?,?)' Делать? Я ожидаю, что это связано с отсутствием контекста. – McDowell

ответ

0

Я получил решение, я поставил следующий код

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

вместо

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

Макдауэлл: Сейчас подходит к 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]); 
} 

Я использовал пример из этого, чтобы создать эту таблицу с динамическим colu МНБ.

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

Благодаря Bauke Luitsen Шольц (BalusC)