: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.

The `repainting` element indicates that the value held by the property never changes over time, even when other properties of the object do change.
When set to "no repaint", the viewer uses this element to not repaint the property after an AJAX update even if some other property/ies of the object have changed.

* for properties, the element can be specified using either the `@PropertyLayout` annotation, or a meta-annotation, or using the `Xxx.layout.xml` layout file.

The element does _not_ apply for action parameters.

The primarily use case for performance, eg can improve the user experience when rendering PDFs/blobs.

IMPORTANT: if there are multiple blobs or clobs, then _all_ must specify "NO REPAINT".
Said another way: if only one blob/clob property requires a repaint, then all will be repainted.

== Annotated

The (no) repainting element can be specified explicitly using an annotation:

* for properties, using `@PropertyLayout#repainting()`:
+
[source,java,indent=0]
----
include::PropertyLayoutRepaintingVm.java[tags=annotation]
----
<.> explicitly specifies that the property should not be repainted
<.> The Wicket pdf.js extension will render this Blob as a PDF

== Layout File

For properties (not parameters), the `renderDay` element can be specified using the `Xxx.layout.xml` file:

* property definition:
+
[source,java,indent=0]
----
include::PropertyLayoutRepaintingVm.java[tags=layout-file]
----
<.> `repainting` hint is _not_ present.

* layout file snippet:
+
[source,xml,indent=0,tabsize=4]
----
<cpt:property id="propertyUsingLayout" repainting="NO_REPAINT"/>
----

One advantage of the layout file over the annotation is that the layout file is dynamic: it can be modified and the changes reloaded in a running application.

TIP: It is sometimes necessary to invoke the `Rebuild Metamodel` action to see this take effect.


== Contributed

The `@PropertyLayout` can also be applied at the class-level to mixin properties:.

[source,java,indent=0]
----
include::PropertyLayoutRepaintingVm_mixinProperty.java[tags=class]
----
<.> explicitly specifies that the contributed property should not be repainted.

== Meta-annotated

The (no) repainting element can also be specified using a custom meta-annotation:

* the meta-annotation is defined as:
+
[source,java]
----
include::RepaintingNoRepaintMetaAnnotation.java[tags=class]
----
<.> annotated for a property (there is no equivalent for parameters)
<.> annotation can be applied to a property (either its getter or the field directly)
<.> annotation can be applied to a type (ie, meta-meta annotations recursively)

* and can be applied to a property:
+
[source,java,indent=0]
----
include::PropertyLayoutRepaintingVm.java[tags=meta-annotated]
----
<.> hint is inherited from the meta-annotation

* or can be applied to mixin:
+
[source,java,indent=0]
----
include::PropertyLayoutRepaintingVm_mixinPropertyWithMetaAnnotation.java[tags=class]
----
<.> hint is inherited from the meta-annotation

=== Meta-annotated Overridden

The meta-annotation can itself be overridden:

* in a property:
+
[source,java,indent=0]
----
include::PropertyLayoutRepaintingVm.java[tags=meta-annotated-overridden]
----
<.> hint from meta-annotation ...
<.> \... is overridden by the `@PropertyLayout` annotation


* or a mixin:
+
[source,java,indent=0]
----
include::PropertyLayoutRepaintingVm_mixinPropertyWithMetaAnnotationOverridden.java[tags=meta-annotation-overridden]
----
<.> hint from meta-annotation ...
<.> \... is overridden by the `@PropertyLayout` annotation

