0

I'm pretty new to JSF and recently I get this error, which I couldn't manage to solve. My intention was to open a dialog which has a picklist in it to select from the list and reload the datatable with the chosen elements.

:

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

My JSF Page:

<!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>

My Controller:

@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();
    }
}

My Stacktrace:

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

My Converter:

@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;
    }
}

Any hints are welcome.

Thanks in advance!

1
  • Why did you change your title this way? Commented Jan 27, 2017 at 16:00

2 Answers 2

3

You want to access a property in your backing bean. The property is not getAllAvailableKomponentDualListModel or allAvailableKomponentDualListModel but komponentenDualListModel

value="#{bestellungLieferantController.komponentDualListModel}"

You already have the setter and getter method in your bean. However, you need to call the method getAllAvailableKomponentDualListModel() before you access it from the view.

Sign up to request clarification or add additional context in comments.

8 Comments

True. But where to initialize the Model? I have a dynamic picklist which will be populated by database values. Therefor I need to call this method.
Add @PostConstruct to the method getAllAvailableKomponentDualListModel().
When I use "@PostConstruct" this method will be invoked once right? And if the user stood in this state for a while and the database values change he wouldn't work on actual data. How can I solve this?
Usually the user interacts with your web app by invoking an action.
Maybe I wasn't precise. Do I need to implement a notify pattern?
|
2

Write like this in p:pickList component value attribute:

value="#{bestellungLieferantController.getAllAvailableKomponentDualListModel}"

Edit just to see try to return something else in this method like this:

@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; 
}

10 Comments

If you look above I just have a value definition. And your syntax is for accessing bean properties not methods. So the brackets are needed.
Removing parenthesis was correct but not sufficient.
please do visit on primefaces homepage to see there is no brackets with methods. for e.g Upload method (file upload) primefaces.org/showcase/ui/file/upload/basic.xhtml
@ArgaPK I'm sorry but I didn't know that. Thanks.
Seems wrong to me. Why is this an answer?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.