将值添加到空dataTable会导致javax.el.PropertyNotFoundException

时间:2016-11-17 09:51:43

标签: java jsf java-ee primefaces

我有一个dataTable,我正在尝试将条目添加到给定表的后备ArrayList中。加载组件后,SelectedStep为null。提供所有Getter和Setter。代码如下:

<p:dataTable 
    id="selectedStepsTable" 
    var="step" 
    value="#{cc.attrs.compBean.componentData[cc.clientId].selectedElement.getData().getSteps()}" 
    selectionMode="single" 
    selection="#{cc.attrs.compBean.componentData[cc.clientId].selectedStep}"
    rowKey="#{step.name}" 
    editable="true" >
      <p:column headerText="Step">
        <p:cellEditor>
            <f:facet name="output"><h:outputText value="#{step.name}" /></f:facet>
          <f:facet name="input"><p:inputText id="stepnameinput" value="#{step.name}" style="width:100%"/></f:facet>
        </p:cellEditor>
      </p:column>
      <p:column headerText="Einheit">
        <p:cellEditor>
            <f:facet name="output"><h:outputText value="#{step.unit.name}" /></f:facet>
          <f:facet name="input">
            <p:autoComplete 
                dropdown="true" 
                value="#{step.unit}" 
                var="stepunit"
                itemLabel="#{stepunit.name}"
                itemValue="#{stepunit}"
                completeMethod="#{cc.attrs.compBean.componentData[cc.clientId].completeUnitName}"
                converter="unitConverter"
                forceSelection="false" />
                            </f:facet>
        </p:cellEditor>
      </p:column>
      <p:column style="width:64px;">
          <f:facet name="header">
            <p:commandLink 
                id="addStepLink" 
                styleClass="ui-icon ui-icon-plus"
                style="display: inline-block" 
                action="#{cc.attrs.compBean.componentData[cc.clientId].addStep}" 
                update=":#{p:component('schrittfrm')}" />
      <p:rowEditor />
      </p:column>
      <p:ajax event="rowSelect" update=":#{p:component('unitdetailgrid')} :#{p:component('stepParamTable')} :#{p:component('unitParamTable')}" />
          <p:ajax event="rowEdit" update=":#{p:component('unitdetailgrid')}" />    
</p:dataTable>

如果选择了一个步骤有关它的单位的详细信息显示在下面的HTML中:

<h:panelGrid id="unitdetailgrid" columns="2" columnClasses="column" cellpadding="5">
    <h:outputLabel for="unitNameInput" value="Name:" />
    <p:inplace id="unitNameInput" effect="none" editor="true">
      <f:facet name="output">
        <h:outputText value="#{empty cc.attrs.compBean.componentData[cc.clientId].selectedStep.unit.name ? 'Einheitsname' : cc.attrs.compBean.componentData[cc.clientId].selectedStep.unit.name}" />
      </f:facet>
      <f:facet name="input">
        <p:autoComplete 
          dropdown="true" 
          value="#{cc.attrs.compBean.componentData[cc.clientId].selectedStep.unit}" 
          var="unitvar"
          itemLabel="#{unitvar.name}"
          itemValue="#{unitvar}"
          completeMethod="#{cc.attrs.compBean.componentData[cc.clientId].completeUnitName}"
          converter="unitConverter"
          forceSelection="false" />
       </f:facet>
    </p:inplace>

    <h:outputLabel for="unitDescriptionInput" value="UnitDescription:" />
    <p:inplace id="unitDescriptionInput" effect="none" editor="true" emptyLabel="UnitDescription">
        <p:inputText value="#{cc.attrs.compBean.componentData[cc.clientId].selectedStep.unit.description}" style="width:100%"/>
    </p:inplace>

现在,如果getSteps()返回一个空的数组/列表,我按下commandLink addStep它会崩溃,我会得到以下Stacktrace:

  

javax.el.PropertyNotFoundException:Target Unreachable,&#39; selectedStep&#39;返回null       在org.apache.el.parser.AstValue.getTarget(AstValue.java:122)       在org.apache.el.parser.AstValue.setValue(AstValue.java:194)       at org.apache.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:260)       在org.jboss.weld.el.WeldValueExpression.setValue(WeldValueExpression.java:64)       at com.sun.faces.facelets.el.ContextualCompositeValueExpression.setValue(ContextualCompositeValueExpression.java:172)       at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:131)       在javax.faces.component.UIInput.updateModel(UIInput.java:832)       在javax.faces.component.UIInput.processUpdates(UIInput.java:749)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       在org.primefaces.component.inplace.Inplace.processUpdates(Inplace.java:237)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at org.primefaces.util.ComponentUtils.processUpdatesOfFacetsAndChilds(ComponentUtils.java:284)       在org.primefaces.component.api.UITabPanel.processUpdates(UITabPanel.java:1108)       在org.primefaces.component.tabview.TabView.processUpdates(TabView.java:336)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       在org.primefaces.component.wizard.Wizard.processUpdates(Wizard.java:192)       在javax.faces.component.UIForm.processUpdates(UIForm.java:281)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       在org.primefaces.component.dialog.Dialog.processUpdates(Dialog.java:430)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       在org.primefaces.component.layout.Layout.processUpdates(Layout.java:254)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       在org.primefaces.component.layout.Layout.processUpdates(Layout.java:254)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1291)       在javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:1254)       at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:78)       在com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)       在com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)       在javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)       在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)       在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)       在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)       at de.istec.pls.client.ui.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:137)       在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)       在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)       在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)       在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)       在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)       at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)       在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)       在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)       在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081)       at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:658)       在org.apache.coyote.http11.Http11NioProtocol $ Http11ConnectionHandler.process(Http11NioProtocol.java:222)       在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1566)       在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.run(NioEndpoint.java:1523)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)       at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)       在java.lang.Thread.run(Thread.java:745)

如果是填充数组,我会得到相同的例外,即我连续添加2个步骤。 如果添加了Step,我会调用:

public void addStep() {
    Step newStep = new Step();
    Unit newUnit = new Unit();
    newStep.setName("Neuer Schritt");
    newStep.setParameters(new ArrayList<StepParameter>());
    newStep.setUnit(newUnit);
    ((DiagramElement) selectedElement.getData()).getSteps().add(newStep);
}

知道我正在使用Primefaces Diagram可能会有所帮助。因此,这些步骤位于Primefaces的元素对象的数据中。

0 个答案:

没有答案