PrimeFaces数据表celledit NullPointerException

时间:2016-05-11 09:10:48

标签: jsf jsf-2 primefaces datatable

我想保存对单元格的更改,但是在添加cellEdit事件时,它会抛出NullPointerException。它无法找到" j_idt_13_cellInfo"请求中的参数。我已经检查了请求中没有带_cellInfo后缀的参数。我错过了什么?我正在使用primefaces 5.3。 我想在第二个示例表中执行与car.brand相同的操作。

2016-05-11T10:25:05.115+0200|Severe: java.lang.NullPointerException
    at org.primefaces.component.datatable.DataTable.queueEvent(DataTable.java:833)
    at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.decode(AjaxBehaviorRenderer.java:129)
    at javax.faces.component.behavior.ClientBehaviorBase.decode(ClientBehaviorBase.java:132)
    at org.primefaces.renderkit.CoreRenderer.decodeBehaviors(CoreRenderer.java:530)
    at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:66)
    at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:832)
    at org.primefaces.component.api.UIData.processDecodes(UIData.java:282)
    at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:573)
    at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
    at org.primefaces.component.api.UIData.visitTree(UIData.java:822)

的Xhtml                           

            <f:ajax event="cellEdit" listener="#{memberManagementController.onCellEdit}"/>

            <p:column headerText="Status">

                <p:cellEditor>
                    <f:facet name="output">
                        <h:outputText value="#{member.status}"/>
                    </f:facet>
                    <f:facet name="input">
                        <h:selectOneMenu value="#{member.status}" style="width:100%">
                            <f:selectItems value="#{memberManagementController.statusLabels}"/>
                        </h:selectOneMenu>
                    </f:facet>
                </p:cellEditor>
            </p:column>
        </p:dataTable>
    </p:panel>
</h:form>

控制器:

@Named("memberManagementController")
@ViewScoped
public class MemberManagementController implements Serializable {
    List<Member> members;
    ...

    public void onCellEdit(CellEditEvent event) {
        System.out.println("hello");
    }

    public List<Integer> getStatusLabels() {
        List<Integer> statusLabels = new ArrayList<>();
        statusLabels.add(1);
        statusLabels.add(2);
        statusLabels.add(3);
        return statusLabels;
    }

0 个答案:

没有答案