What to do when a javax.el.PropertyNotWritableException occurs

Event: I was angry that I could not set a value for Bean when I executed submit processing from the screen

--Environment --Windows10 64bit version 1909 - openjdk 11 2018-09-25 - Eclipse IDE for Enterprise Java Developers Version: 2020-09 (4.17.0) - JSF 2.3.9 - Payara Server 5.194

javax.el.PropertyNotWritableException: /admin/ponsuke/ponsuke.xhtml @52,92 value="#{item.mailAddress}": The class 'jp.co.my.app.Item' does not have a writable property 'mailAddress'.
    at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:99)
    at javax.faces.component.UIInput.updateModel(UIInput.java:859)
    at javax.faces.component.UIInput.processUpdates(UIInput.java:773)
    at com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:571)

To Bean ...

<!--abridgement-->
  <ui:repeat var="category" varStatus="index" value="#{ponsukeController.categories}">
    <ui:repeat var="item" varStatus="status" value="#{category.itemList}">
        <td class="form-inline">
          <h:inputText value="#{item.mailAddress}" />
<!--abridgement-->

No Setter?

PonsukeController


//abridgement
/**Category information list. */
@Getter
@Setter
private List<Category> categories;
//abridgement

Cause: The child class does not have @Setter

Ahhhh, @ Value didn't include @ Setter ...

In practice, @Value is shorthand for: final @ToString @EqualsAndHashCode @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @Getter, except that explicitly including an implementation of any of the relevant methods simply means that part won't be generated and no warning will be emitted. @Value - projectlombok.org

Category


import lombok.Value;

@Value
public class Category {
    List<Item> itemList;
}

Item


import lombok.Value;

@Value
public class Item {
    int itemId;
    String mailAddress;
}

Action: Change the annotation of the class with the property to be set

This time @Value is stuck and I'm using the role of @AllArgsConstructor elsewhere, so [@Getter @AllArgsConstructor] + [@Setter] = [@Data @AllArgsConstructor] I decided to change to. Since the property of class Category is List and only the contents are changed, the annotation is not changed.

Item


import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Item {
//abridgement

By the way If you add @Setter to each of the ʻitemList and mailAddressproperties, a compile error will occur. PropertyNotWritableException occurred even if@Setter was added to class in addition to @Value. I think it's because there is @FieldDefaults (makeFinal = true, level = AccessLevel.PRIVATE)`.

To add final to each (instance) field, use @FieldDefaults(makeFinal=true). Any non-final field which must remain nonfinal can be annotated with @NonFinal (also in the lombok.experimental package). @FieldDefaults - projectlombok.org

Recommended Posts

What to do when a javax.el.PropertyNotWritableException occurs
What to do when javax.batch.operations.JobStartException occurs
What to do when a null byte error occurs
What to do when IllegalStateException occurs in PlayFramework
Notes on what to do when a WebView ClassNotFoundException occurs in JavaFX 12
What to do when rails creates a 〇〇 2.rb file
Error ExecJS :: RuntimeUnavailable: What to do when it occurs
What to do when undefined method ʻuser_signed_in?'
What to do when you become a Problem During Content Assist
What to do when you run into a docker-compose node_modules problem
What to do if a SAX Parser error occurs when using Liferay 7 / DXP on AWS
[Rails 6] What to do when a missing a template error occurs after introducing haml [Super easy]
What to do when debugging "Source not found"
What do you use when converting to String?
What to do and how to install when an error occurs in DXRuby 1.4.7
What to do if an error occurs when nokogiri enters when bundle install
What to do when "call'Hoge.connection' to establish a connection" appears on rails c
What to do when you want to delete a migration file that is "NO FILE"
<f: ajax> Unable to attach <f: ajax> to non-ClientBehaviorHolder What to do when you become a parent
What to do when JSF tags do not become HTML
What to do if you accidentally create a model
What to do if an ActionController :: UnknownFormat error occurs
What to do when is invalid because it does not start with a'-'
ParseException: What to do when Unparseable date is reached
[Ubuntu] What to do when MongoDB cannot be started due to a SocketException error
What to do if you get a NoClassDefFoundError when trying to run eclipse on Java9
What to do if you get a port error when docker-compose up on Mac
What to do when it becomes Unable to find CDI BeanManager.
What to do when Method not found in f: ajax
What to do when you launch an application with rails
What to do when Cannot apply expression operators to method binding
What to do if mysql2 gets a bundle install error
What to do after Vagrant install
What to do when Cannot format given Object as a Date in convertDateTime of JSF
[Ruby / Rails] What to do when NoMethodError appears when using a destructive method such as filter!
What to do when a could not find driver appears when connecting to a DB in a Docker environment
[Rails Tutorial Chapter 2] What to do when you make a mistake in the column name
What to do if you get a "Cannot Pull Container Error" when starting ECS ​​Fargate
[Rails] What to do when the view collapses when a message is displayed with the errors method
What to do when the changes in the Servlet are not reflected
[Rails] What to do when rails s does not respond or does not stop
What to do if you get a DISPLAY error in gym.render ()
java.security.InvalidKeyException: What to do when Illegal key size or default parameters
What to do if you get a JNI shared library error when trying to build in Eclipse
What to do if an error occurs when doing npm install axios in React + Typescript project
What to do when javax.el.ELException: Not a Valid Method Expression: appears when the JSF screen is displayed
What to do after updating Dockerfile, docker-compose.yml
A reminder when an aapt.exe error occurs
What to do if you install Ubuntu
[IOS] What to do when the image is filled with one color
What to do if you get a groovy warning in Thymeleaf Layout
What to do when CentOS cannot be started with VirtualBox on Catalina
What to do when "npm ERR! Code ENOSELF" is displayed after npm install
What to do when Blocked Host: "host name" appears in Ruby on Rails
no space left on device What to do if an error occurs
Notes on what to do when EC2 is set up with t2.micro
What to do if tomcat process remains when tomcat is stopped in eclipse
What to do if you get an error when you hit Heroku logs
What to do if you get a MiniMagick vulnerability alert on GitHub
What to do if zip dies if there is a pom when making an executable jar with gradle
What to do if Operation not permitted is displayed when you execute a command in the terminal