=== Editing

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
:page-partial:


The xref:applib:index/annotation/Property.adoc#editing[editing()] element can be used to prevent a property from being modified or cleared, ie to make it read-only.

The related xref:applib:index/annotation/Property.adoc#editingDisabledReason[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 xref:refguide:applib:index/annotation/DomainObject.adoc#editing[@DomainObject#editing()] element

* else (that is, if the domain object's editability is specified as being `AS_CONFIGURED`), then the value of the xref:refguide:config:sections/causeway.applib.adoc#causeway.applib.annotation.domain-object.editing['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 xref:refguide:applib-methods:prefixes.adoc#disable[disable...()] supporting methods


Thus, to make a property read-only even if the object would otherwise be editable, use:

[source,java]
----
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;
}
----


