javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation

Look at the stack trace. Here’s the most important part:

Caused by: javax.faces.component.UpdateModelException: javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation
    at javax.faces.component.UIInput.updateModel(UIInput.java:853)
    at javax.faces.component.UIInput.processUpdates(UIInput.java:735)
    at javax.faces.component.UIData.iterate(UIData.java:2001)
    at javax.faces.component.UIData.processUpdates(UIData.java:1253)
    at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1242)
    at javax.faces.component.UIForm.processUpdates(UIForm.java:281)
    at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1242)
    at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:1231)
    at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:78)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    ... 26 more

Read from bottom to top. During update model values phase, JSF is traversing the component tree starting from UIViewRoot component (<f:view>). In an UIForm component (<h:form>) there is an UIData component (<h:dataTable>) which has an UIInput component (<h:inputText>) which needs to be processed. The updateModel() basically needs to put the submitted, converted and validated value in the model (the managed bean). However, that operation has failed because the property is not writable (i.e. the setter method cannot be found based on the EL expression syntax).

Well, let’s look at the properties of your <h:inputText> components in general.

<h:inputText value="#{p.getId}"/>
...
<h:inputText value="#{p.getNazwa}" />
...
<h:inputText value="#{p.getNip}" />

Wait, that’s strange. They start all with “get”! This is definitely not normal. JSF is then looking for methods like setGetId(), setGetNazwa(), etc which just doesn’t make sense (and you likely also don’t have, given this exception). It’s expected that they represent concrete property names like “id”, “nazwa”, “nip”, etc and not full method names.

Thus, so in the model:

private Long id;
private String nazwa;
private String nip;

// Add/generate getters and setters in the following syntax:

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

// ...

And so in the view:

<h:inputText value="#{p.id}"/>
...
<h:inputText value="#{p.nazwa}" />
...
<h:inputText value="#{p.nip}" />

This is however already covered in a bit sane JSF book/tutorial/resource. Are you absolutely positive that you were reading the right one? Your question also shows that you’re using JSF 2.0 in combination with the deprecated JSP view technology instead of its successor Facelets. Start at our JSF wiki page.

Leave a Comment