javax.servlet.ServletException:<p:ajax>事件:不支持rowEdit </p:ajax>

时间:2013-04-24 13:19:44

标签: jsf jsf-2 primefaces xhtml

尝试使用PrimeFaces时,我收到一条错误消息,让每行都可编辑。我在线检查很多人正在利用这个。但是当我尝试创建一个包含报告的页面时,每个行都可以编辑。我得到的错误是Event:rowEdit不受支持。有人可以指出我的错误或我需要包含在我的XHTML文件中的东西。或者如果我正在做正确的事情。 这张表有很多数据,这就是我采用这种方法的原因

以下是有关我的设置的其他信息:

  1. Glassfish v3
  2. JPA2.1
  3. PrimeFaces3.5(我的项目构建路径中包含jar,因为其他报告页面正在努力确认primefaces正在运行)
  4. EJB 3.1
  5. 这是我的XHTML代码

    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:p="http://primefaces.org/ui">
    
    <f:metadata>
        <f:viewParam name="userId" value="#{loginBean.username}"></f:viewParam>
    </f:metadata>
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <link href="./css/PageLayout.css" rel="stylesheet" type="text/css" />
    
        <title>Edit Lord of Data Entries</title>
    </h:head>
    <h:body>
    
        <div style="background-color: #205a8c; width: auto; height: 60px">
            <h3>Edit Lord Of Data</h3>
        </div>
        <div id="breadcrumb" align="left">
            <h:form>
                <p:breadCrumb>
                    <p:menuitem value="Home" url="home.jsf"></p:menuitem>
                    <p:menuitem value="Home" url="home.jsf"></p:menuitem>
                    <p:menuitem value="Users" url="reportUsers.jsf"></p:menuitem>
                    <p:menuitem value="Groups" url="reportGroups.jsf"></p:menuitem>
                    <p:menuitem value="User's Group" url="reportUserGroup.jsf"></p:menuitem>
                </p:breadCrumb>
            </h:form>
        </div>
        <h:form id="form">
            <p:growl id="messages" showDetail="true"></p:growl>
            <p:dataTable var="myReport"  
                value="#{lordOfDataAdminManagedBean.lodAdmin_list}" id="lodlist"
                editable="true" paginator="true"
                rows="500"
                    paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                    rowsPerPageTemplate="500,1000,5000">
    
                <f:facet name="header"> Lord Of Data Report</f:facet>
    
                <p:ajax event="rowEdit"
                    listener="#{lordOfDataAdminManagedBean.onEditListener}"></p:ajax>
                <p:ajax event="rowEditCancel"
                    listener="#{lordOfDataAdminManagedBean.onCancel}"></p:ajax>
    
                <p:column>
                    <p:rowEditor></p:rowEditor>
                </p:column>
                <p:column headerText="Row Id">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.rowId}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.rowId}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="Group Id">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.security}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.security}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
    
                <p:column headerText="Type">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.type}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.type}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="Auto">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.auto}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.auto}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="Access">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.access}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.access}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="Comment">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.comment}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.comment}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="LOD1 Domain">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.LOD1Domain}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.LOD1Domain}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="LOD1 User">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.LOD1User}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.LOD1User}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="LOD1 Mail">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.LOD1Mail}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.LOD1Mail}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="LOD1 Display Name">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.LOD1DisplayName}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.LOD1DisplayName}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="LOD1 Cost Center">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.LOD1CostCenter}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.LOD1CostCenter}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="LOD2 User">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.LOD2User}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.LOD2User}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
    
                <p:column headerText="LOD2 Mail">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.LOD2Mail}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.LOD2Mail}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="LOD2 Display Name">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.LOD2DisplayName}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.LOD2DisplayName}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="LOD2 Cost Center">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.LOD2CostCenter}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.LOD2CostCenter}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="Domain1">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.domain1}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.domain1}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="RechteGruppe Read">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.rechteGruppeRead}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.rechteGruppeRead}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="AuthentifizierteBenutzer">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.authentifizierteBenutzer}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.authentifizierteBenutzer}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="LOD2 Domain">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.LOD2Domain}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.LOD2Domain}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="Email Send Status">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.emailSendStatus}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.emailSendStatus}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="Email Feedback">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.emailFeedback}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.emailFeedback}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="Comment1">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.comment1}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.comment1}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="Comment2">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.comment2}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.comment2}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="Comment 3">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.comment3}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.comment3}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
                <p:column headerText="Username">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.username}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.username}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
    
    
            </p:dataTable>
        </h:form>
    
    </h:body>
    
    </html>
    

    用于处理编辑功能的托管Bean代码段

    public void onEditListener(RowEditEvent event) {
    
            FacesMessage msg = new FacesMessage("Edited");
    
            try {
                Lodreport mydata = (Lodreport) event.getObject();
                if (mydata == null) {
                    System.out.println("No data input found");
                } else {
                    lODBR.updateReport(mydata);
                    FacesContext.getCurrentInstance().addMessage(null, msg);
                }
            } catch (Exception e) {
    
            }
        }
    
         public void onCancel(RowEditEvent event) {  
             FacesMessage msg = new FacesMessage("Cancelled");
             FacesContext.getCurrentInstance().addMessage(null, msg);
         }
    

    错误堆栈跟踪

    WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
    javax.faces.view.facelets.TagException: /editNewLODAdmin.xhtml @44,7 <p:ajax> Event:rowEdit is not supported.
        at org.primefaces.component.behavior.ajax.AjaxBehaviorHandler.applyAttachedObject(AjaxBehaviorHandler.java:149)
        at org.primefaces.component.behavior.ajax.AjaxBehaviorHandler.apply(AjaxBehaviorHandler.java:127)
        at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
        at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
        at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
        at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
        at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
        at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
        at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
        at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
        at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
        at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
        at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
        at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
        at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:774)
        at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:223)
        at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:188)
        at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:453)
        at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
        at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        at java.lang.Thread.run(Thread.java:722)
    

2 个答案:

答案 0 :(得分:1)

这不起作用,因为

  1. 从技术上讲,您没有为表添加行编辑支持,而是在编辑单元格。在表格中添加<p:rowEditor/>以挂钩rowEdit事件

  2. 你的桌子,它不是真正的桌子。 <p:dataTable/>标记实际上并不包含<p:column/>或其他任何内容

  3. 你应该拥有什么:

        <p:dataTable var="myReport" value="#{lordOfDataAdminManagedBean.lodAdmin_list}" id="lodlist" editable="true">
    
                <f:facet name="header"> Lord Of Data Report</f:facet>
    
                <p:ajax event="rowEdit"
                    listener="#{lordOfDataAdminManagedBean.onEditListener}"
                    ></p:ajax>
                <p:ajax event="rowEditCancel"
                    listener="#{lordOfDataAdminManagedBean.onCancel}"
                    ></p:ajax>
    
                <p:column headerText="Row Id">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.rowId}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.rowId}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column>
                    <p:rowEditor />
                </p:column>
         </p:dataTable>
    

答案 1 :(得分:-1)

我明白了:

<p:dataTable var="myReport"
                    value="#{lordOfDataAdminManagedBean.lodAdmin_list}" id="lodlist"
                    editable="true"></p:dataTable>

                <f:facet name="header"> Lord Of Data Report</f:facet>

                <p:ajax event="rowEdit"
                    listener="#{lordOfDataAdminManagedBean.onEditListener}"
                    ></p:ajax>
                <p:ajax event="rowEditCancel"
                    listener="#{lordOfDataAdminManagedBean.onCancel}"
                    ></p:ajax>

                <p:column headerText="Row Id">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{myReport.rowId}"></h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{myReport.rowId}"></p:inputText>
                        </f:facet>
                    </p:cellEditor>
                </p:column>

你必须尝试:

    <p:dataTable var="myReport"
                        value="#{lordOfDataAdminManagedBean.lodAdmin_list}" id="lodlist"
                        editable="true">

                    <f:facet name="header"> Lord Of Data Report</f:facet>

                    <p:ajax event="rowEdit"
                        listener="#{lordOfDataAdminManagedBean.onEditListener}"
                        ></p:ajax>
                    <p:ajax event="rowEditCancel"
                        listener="#{lordOfDataAdminManagedBean.onCancel}"
                        ></p:ajax>

                    <p:column headerText="Row Id">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{myReport.rowId}"></h:outputText>
                            </f:facet>
                            <f:facet name="input">
                                <p:inputText value="#{myReport.rowId}"></p:inputText>
                            </f:facet>
                        </p:cellEditor>
                    </p:column>
</p:dataTable>