2017-01-27 20 views
0

私はJSFの新機能を使用していますが、最近このエラーが発生しました。私の意図は、リストから選択し、選択した要素でデータテーブルをリロードするためのピックリストを持つダイアログを開くことでした。エラーレンダリングビュー[dummy.xhtml]:java.lang.NullPointerException

13:47:22,873 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (default task-72) javax.faces.component.UpdateModelException: javax.el.PropertyNotWritableException: /forms/bestellungLieferant.xhtml @29,29 value="#{bestellungLieferantController.getAllAvailableKomponentDualListModel()}": Illegal Syntax for Set Operation

マイJSFページ:

<!DOCTYPE HTML> 
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:p="http://primefaces.org/ui"> 

<f:view> 
    <f:metadata> 
     <!-- Start working on a task. Task Id is read internally from 
     request parameters and cached in the CDI conversation scope. 
    --> 

     <f:event type="preRenderView" 
      listener="#{camundaTaskForm.startTaskForm()}" /> 
    </f:metadata> 
    <h:head> 
     <title>Paket zusammenstellen</title> 
    </h:head> 
    <h:body> 
     <p:dialog id="komponentenAuswahlDialog" header="Komponenten auswählen" 
      widgetVar="komponentenAuswahlDialog" modal="true" height="auto" 
      width="auto" immediate="true" rendered="true"> 
      <p:pickList converter="entityConverter" 
       id="komponenteAuswahlPickList" 
       value="#{bestellungLieferantController.getAllAvailableKomponentDualListModel()}" 
       var="komponente" itemLabel="#{komponente.serienNummer}" 
       itemValue="#{komponente.id}" showSourceFilter="true" 
       showTargetFilter="true"> 
       <f:facet name="sourceCaption">Quelle</f:facet> 
       <f:facet name="targetCaption">Ziel</f:facet> 
      </p:pickList> 
      <h:form> 
       <p:commandButton update="komponenteTable" value="Auswahl speichern" 
        oncomplete="PF('komponentenAuswahlDialog').hide();" /> 
      </h:form> 
     </p:dialog> 
     <h:panelGrid id="paketInformationPG" columns="2" border="1"> 
      <f:facet name="header"> 
       <h:outputText value="Paket zusammenstellen" /> 
      </f:facet> 
      <h:outputLabel value="Kunde:" /> 
      <h:outputText value="#{processVariables['kunde']}" /> 

      <h:outputLabel value="Betriebssystem:" /> 
      <h:outputText value="Platzhalter" /> 

      <h:outputLabel value="Benutzer:" /> 
      <h:outputText value="#{processVariables['benutzerName']}" /> 
     </h:panelGrid> 
     <h:panelGrid id="komponentenZusammenstellungPG" columns="2" border="1"> 
      <f:facet name="header"> 
       <h:panelGrid columns="2"> 
        <h:outputText value="Komponenten" /> 
        <h:commandButton type="button" 
         onclick="PF('komponentenAuswahlDialog').show();" value="+" /> 
       </h:panelGrid> 
      </f:facet> 
      <p:dataTable id="komponenteTable" widgetVar="komponenteTable" 
       var="komponente" 
       value="#{bestellungLieferantController.komponentenList}"> 
       <p:column> 
        <f:facet name="header">Typ</f:facet> 
        <h:outputText value="#{komponente.produkt.typ.name}" /> 
       </p:column> 

       <p:column> 
        <f:facet name="header">Bezeichnung</f:facet> 
        <h:outputText value="#{komponente.produkt.name}" /> 
       </p:column> 

       <p:column> 
        <f:facet name="header">SN</f:facet> 
        <h:outputText value="#{komponente.serienNummer}" /> 
       </p:column> 

       <p:column headerText="Kaufdatum"> 
        <f:facet name="header">Kaufdatum</f:facet> 
        <h:outputText value="#{komponente.bestellDatum}" /> 
       </p:column> 

       <p:column> 
        <f:facet name="header">Aktion</f:facet> 
        <p:commandLink value="Bearbeiten" /> 
        <p:commandLink value="Enfernen" /> 
       </p:column> 
      </p:dataTable> 
     </h:panelGrid> 
    </h:body> 
</f:view> 
</html> 

マイコントローラー:

@ManagedBean 
@SessionScoped 
public class BestellungLieferantController implements Serializable{ 

    @EJB 
    private BestellungFacade bestellungFacade; 

    @EJB 
    private PaketFacade paketFacade; 

    @EJB 
    private KomponenteFacade komponenteFacade; 

    @EJB 
    private BetriebssystemFacade betriebssystemFacade; 

    // Komponent-List with added komponent items 
    private List<Komponente> komponentenList = new ArrayList<Komponente>(); 

    private DualListModel<Komponente> komponentenDualListModel; 

    public DualListModel<Komponente> getKomponentenDualListModel() { 
     return komponentenDualListModel; 
    } 

    public void setKomponentenDualListModel(DualListModel<Komponente> komponentenDualListModel) { 
     this.komponentenDualListModel = komponentenDualListModel; 
    } 

    public List<Komponente> getKomponentenList() { 
     return komponentenList; 
    } 

    public void setKomponentenList(List<Komponente> komponentenList) { 
     LogManager logManager = LogManager.getLogManager(); 
     Logger rootLogger = logManager.getLogger("DUMMY"); 
     rootLogger.setLevel(Level.ALL); 
     rootLogger.info("KomponentenList"); 
     this.komponentenList = komponentenList; 
    } 


    /** 
    * Gets the actual Model with the distinct source and 
    * @param targetList 
    * @return 
    */ 
    public DualListModel<Komponente> getAllAvailableKomponentDualListModel(){ 
     List<Komponente> sourceKomponenteList = this.komponenteFacade.getAllAvailableKomponente(); 
     List<Komponente> sourceKomponenteDistinctList = new ArrayList<Komponente>(); 

     if (this.komponentenList.size() != 0){ 
      for(Komponente k : sourceKomponenteList){ 
       if (!komponentenList.contains(k)){ 
        sourceKomponenteDistinctList.add(k); 
       } 
      } 
     } else { 
      sourceKomponenteDistinctList = sourceKomponenteList; 
     } 


//  komponentenDualListModel.setSource(sourceKomponenteDistinctList); 
//  komponentenDualListModel.setTarget(komponentenList); 

     this.setKomponentenDualListModel(new DualListModel<Komponente>()); 
     this.getKomponentenDualListModel().setSource(sourceKomponenteDistinctList); 
     this.getKomponentenDualListModel().setTarget(this.komponentenList); 



     return this.getKomponentenDualListModel(); 
    } 

    public void putSelectionIntoKomponenteList(){ 
     LogManager logManager = LogManager.getLogManager(); 
     Logger rootLogger = logManager.getLogger("DUMMY"); 
     rootLogger.setLevel(Level.ALL); 
     rootLogger.info("PutSelectionIntoKomponentList"); 
     rootLogger.info("KOMPONENTELIST: " + komponentenDualListModel.getTarget()); 
     this.komponentenList = this.komponentenDualListModel.getTarget(); 
    } 
} 

私のスタックトレース:

13:47:22,873 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (default task-72) javax.faces.component.UpdateModelException: javax.el.PropertyNotWritableException: /forms/bestellungLieferant.xhtml @29,29 value="#{bestellungLieferantController.getAllAvailableKomponentDualListModel()}": Illegal Syntax for Set Operation 
    at javax.faces.component.UIInput.updateModel(UIInput.java:866) 
    at org.primefaces.component.picklist.PickList.updateValue(PickList.java:530) 
    at org.primefaces.component.picklist.PickList.validateValue(PickList.java:394) 
    at javax.faces.component.UIInput.validate(UIInput.java:982) 
    at org.primefaces.component.picklist.PickList.validate(PickList.java:424) 
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1248) 
    at javax.faces.component.UIInput.processValidators(UIInput.java:712) 
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261) 
    at org.primefaces.component.dialog.Dialog.processValidators(Dialog.java:423) 
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261) 
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261) 
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195) 
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76) 
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658) 
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) 
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) 
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) 
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) 
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) 
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) 
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) 
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) 
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) 
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292) 
    at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81) 
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138) 
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135) 
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) 
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) 
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272) 
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81) 
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104) 
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202) 
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: javax.el.PropertyNotWritableException: /forms/bestellungLieferant.xhtml @29,29 value="#{bestellungLieferantController.getAllAvailableKomponentDualListModel()}": Illegal Syntax for Set Operation 
    at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:136) 
    at javax.faces.component.UIInput.updateModel(UIInput.java:832) 
    ... 53 more 
Caused by: javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation 
    at com.sun.el.parser.AstValue.setValue(AstValue.java:228) 
    at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:294) 
    at org.jboss.weld.el.WeldValueExpression.setValue(WeldValueExpression.java:64) 
    at org.jboss.weld.el.WeldValueExpression.setValue(WeldValueExpression.java:64) 
    at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:131) 
    ... 54 more 

マイコンバーター:

@FacesConverter(value = "entityConverter") 
public class EntityConverter implements Converter { 

    private static Map<Object, String> entities = new WeakHashMap<Object, String>(); 

    @Override 
    public String getAsString(FacesContext context, UIComponent component, Object entity) { 
     synchronized (entities) { 
      if (!entities.containsKey(entity)) { 
       String uuid = UUID.randomUUID().toString(); 
       entities.put(entity, uuid); 
       return uuid; 
      } else { 
       return entities.get(entity); 
      } 
     } 
    } 

    @Override 
    public Object getAsObject(FacesContext context, UIComponent component, String uuid) { 
     for (Entry<Object, String> entry : entities.entrySet()) { 
      if (entry.getValue().equals(uuid)) { 
       return entry.getKey(); 
      } 
     } 
     return null; 
    } 
} 

ご意見は歓迎します。

ありがとうございます!

+0

なぜあなたのタイトルをこのように変更しましたか? – Kukeltje

答えて

1

p:pickListコンポーネントvalue属性で、このような書き込み:

value="#{bestellungLieferantController.getAllAvailableKomponentDualListModel}" 

編集 ちょうどこのようにこの方法で何かを返すようにしてみてください参照するには:

@Override 
public Object getAsObject(FacesContext context, UIComponent component, String uuid) { 
for (Entry<Object, String> entry : entities.entrySet()) { 
if (entry.getValue().equals(uuid)) { 
return entry.getKey(); 
} 
} 
return uuid; 
} 
+0

上記を見れば、私は値の定義をしているだけです。また、構文ではなくメソッドにアクセスするための構文もあります。したがって、括弧が必要です。 – LupoZ

+0

括弧を削除することは正しいが、十分ではなかった。 – JanPl

+0

primefacesのホームページにアクセスして、メソッドの括弧がないことを確認してください。アップロード方法(ファイルアップロード)http://www.primefaces.org/showcase/ui/file/upload/basic.xhtml – ArgaPK

3

あなたがアクセスしたいですあなたのバッキングビーンのプロパティ。プロパティは、あなたはすでにあなたのBean内のセッターとゲッターメソッドを持っているgetAllAvailableKomponentDualListModelallAvailableKomponentDualListModelではなく、komponentenDualListModel

value="#{bestellungLieferantController.komponentDualListModel}" 

。ただし、ビューからアクセスする前にgetAllAvailableKomponentDualListModel()メソッドを呼び出す必要があります。

+0

真。しかし、モデルを初期化する場所はどこですか?私は、データベース値によって入力される動的ピックリストを持っています。そのため、私はこのメソッドを呼び出す必要があります。 – LupoZ

+1

@PostConstructをメソッドgetAllAvailableKomponentDualListModel()に追加します。 – JanPl

+0

"@PostConstruct"を使用すると、このメソッドは一度正しく呼び出されますか?また、ユーザーがしばらくこの状態になっていて、データベース値が変更された場合、彼は実際のデータでは動作しません。これをどうすれば解決できますか? – LupoZ