javax.el.PropertyNotWritableException: Illegal Syntax for Set Operation

You have few problems here. First, in your input components you have values like p.getId. In your bean, you probably have methods called getId and setId, but this means that you have property called just id which you can read and write. So change your values to: p.id, p.nazwa, p.nip... You can see that I'm using all lower letters, not Id but id.

Second, you should change your action method to something like this (if you want redirect):

public String redirect() {
  return "dodaj_pr?faces-redirect=true";
}

and command button tag to something like this:

<h:commandButton action="#{producentBean.redirect}" value="Dodaj" />

I had the same mistake. The error was that in the value property of the inputext in the EL there were blank spaces between } and " as shown below.

<h:inputText id="txtNroOficio" value="# {bean.nombre}  "   />

I deleted the blank spaces and it worked.


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.

Tags:

Jsf