Editing
The editing() element can be used to prevent a property from being modified or cleared, ie to make it read-only.
The related editingDisabledReason() element specifies a hard-coded reason why the property cannot be modified directly.
Whether a property is enabled or disabled depends upon these factors:
-
whether the domain object has been configured as immutable through the @DomainObject#editing() element
-
else (that is, if the domain object’s editability is specified as being
AS_CONFIGURED), then the value of the 'causeway.applib.annotation.domain-object.editing' configuration property.If set to
false, then the object’s properties (and collections) are not editable -
else, the value of the
@Property(editing=…)attribute itself -
else, the result of invoking any supporting disable…() supporting methods
Thus, to make a property read-only even if the object would otherwise be editable, use:
import lombok.Getter;
import lombok.Setter;
public class Customer {
@Property(
editing=Editing.DISABLED,
editingDisabledReason =
"The credit rating is derived from multiple factors"
)
@Getter @Setter
private int initialCreditRating;
}