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