0

我正在支持 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"/>

如何解决上述错误。

4

1 回答 1

0

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

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)

于 2011-08-25T13:24:30.787 回答