--Environnement --Windows10 version 64 bits 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)
Être un ...
<!--réduction-->
<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}" />
<!--réduction-->
Pas de Setter?
PonsukeController
//réduction
/**Liste d'informations sur la catégorie. */
@Getter
@Setter
private List<Category> categories;
//réduction
@ SetterAhhhh, @ Value n'incluait pas @ Setter ...
In practice,
@Valueis 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;
}
Cette fois, @ Value est attaché, et j'utilise le rôle de @ AllArgsConstructor ailleurs, donc
[@Getter @AllArgsConstructor] + [@Setter] = [@Data @AllArgsConstructor]
J'ai décidé de changer pour.
Puisque la propriété de class Category est List et que seul le contenu est modifié, l'annotation n'est pas modifiée.
Item
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class Item {
//réduction
Au fait
Si vous ajoutez @ Setter à chacune des propriétés ʻitemList et mailAddress, une erreur de compilation se produira. PropertyNotWritableException se produisait même si «@ Setter» était ajouté à la classe en plus de «@ Value». Je pense que c'est probablement parce qu'il y a @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