0

我有一个关于 Primefaces 的问题orderList

我有一个如下所示的 orderList:

<p:orderList id="technikersTable"
                        value="#{systemlandschaftRessourceHandler.entity.technikers}" 
                        var="_techniker"  
                        itemValue="#{_techniker}" 
                        converter="#{entityConverter}"
                        controlsLocation="none">  

                <f:facet name="caption">Techniker</f:facet>  

                <p:column>
                    <p:commandButton styleClass="colButton" 
                                    icon="ui-icon-trash" 
                                    action="#{systemlandschaftRessourceHandler.removeTechniker(_techniker)}" 
                                    update=":systemLandschaftTabView:sysObjektDetailPanelForm:technikersTable"/>
                </p:column>
                <p:column style="width:75%;">  
                   <p:outputLabel value="#{_techniker.verantwortlich.displayName}" />
                </p:column>

            </p:orderList>

我的问题是,第一列中的 commandButton 引发了空指针异常。该请求永远不会到达我的bean。

commandButton 是否可能在 orderList 中不起作用?我已经成功地用 dataTables 做了很多时间。

堆栈跟踪:

    ERROR 2013-10-15 14:37:55,009 [MmnetExceptionHandler] Fehler auf der Seite: /views/protected/systemlandschaft/systemlandschaftHome.xhtml, isAjaxRequest=true
ERROR 2013-10-15 14:37:55,010 [MmnetExceptionHandler] [SCUE070] Allgemeiner Anwendungsfehler! : java.lang.NullPointerException
    at java.lang.Class.isAssignableFrom(Native Method)
    at org.apache.el.util.ReflectionUtil.isAssignableFrom(ReflectionUtil.java:319)
    at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:185)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:257)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
    at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39)
    at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at org.apache.myfaces.extensions.cdi.jsf.impl.security.SecurityViolationAwareActionListener.processAction(SecurityViolationAwareActionListener.java:56)
    at org.apache.myfaces.extensions.cdi.jsf.impl.config.view.ViewControllerActionListener.processAction(ViewControllerActionListener.java:68)
    at org.apache.myfaces.extensions.cdi.jsf.impl.listener.action.CodiActionListener.processAction(CodiActionListener.java:58)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIData.broadcast(UIData.java:1093)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.execute(CodiLifecycleWrapper.java:95)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
    at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
    at de.company.mmnet.sessioninfo.HttpSessionUserFilter.doFilter(HttpSessionUserFilter.java:42)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:101)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:165)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931)
    at java.lang.Thread.run(Thread.java:722)

DEBUG 2013-10-15 14:37:55,094 [EntityManagerProducer] EntityManager geschlossen.
4

2 回答 2

1

您可以在 orderList 中使用命令按钮。您的问题是您使用 #{_techniker} var 作为参数。当您单击按钮时,action 属性正在评估服务器端的 EL 表达式,这导致了空指针。

它确实在数据表中工作,但数据表组件的设计不同。

我会考虑使用不同的组件,但如果你真的需要使用 orderlist,你可以使用 p:remoteCommand 将技术人员的 id 发送到支持 bean。

Primefaces 远程命令

于 2013-10-16T06:08:49.240 回答
0

扩展 LStrike 评论,这里是来自https://forum.primefaces.org/viewtopic.php?f=3&t=34424的相关内容

豆:

@ManagedBean
@RequestScoped
public class TechnikersBean {
    public List<String> getPersons() {
        List<String> result = new ArrayList<String>();

        result.add("Person1");
        result.add("person2");
        return result;
    }

    public void setPersons(List<String> persons) {

    }

    public void removeTechniker(ActionEvent event) {
        Map<String, String> parameterMap = FacesContext.getCurrentInstance().getExternalContext()
                .getRequestParameterMap();
        String name = parameterMap.get("name");
        System.out.println(name);
    }
}

xhtml:

<h:form id="form">
    <p:remoteCommand name="removeTechniker" actionListener="#{technikersBean.removeTechniker}"
                     out="technikersTable" />

    <p:orderList id="technikersTable"
                 value="#{technikersBean.persons}"
                 var="_techniker"
                 itemValue="#{_techniker}"
                 controlsLocation="none">

        <f:facet name="caption">Techniker</f:facet>

        <p:column>
            <p:commandButton styleClass="colButton"
                             icon="ui-icon-trash"
                             type="button" onclick="removeTechniker([{name:'name', value:'#{_techniker}'}]);">
                    </p:commandButton>
        </p:column>
        <p:column style="width:75%;">
            <p:outputLabel value="#{_techniker}"/>
        </p:column>

    </p:orderList>
</h:form>

基本上,remoteComand 由客户端回调调用以将所需信息发送到 bean 函数。

于 2017-07-27T12:21:58.303 回答