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

Part of the _Publishing SPI_ . A component to receive notifaction that a domain object or a standalone list of domain objects has been rendered.

== API

[source,java]
.PageRenderSubscriber.java
----
interface PageRenderSubscriber {
  void onRendering(PageType pageType)     // <.>
  void onRenderedDomainObject(Bookmark bookmark)     // <.>
  void onRenderedCollection(Supplier<List<Bookmark>> bookmarkSupplier)     // <.>
  void onRenderedValue(Object value)     // <.>
}
----

<.> xref:#onRendering_PageType[onRendering(PageType)]
+
--
Called just before the rendering process starts.However, if _PageType#OTHER_ , then *NO*  `onRenderedXxx` method will be called.
--
<.> xref:#onRenderedDomainObject_Bookmark[onRenderedDomainObject(Bookmark)]
+
--
Indicates that the domain object represented by the xref:refguide:applib:index/services/bookmark/Bookmark.adoc[Bookmark] has been rendered.
--
<.> xref:#onRenderedCollection_Supplier[onRenderedCollection(Supplier)]
+
--
Indicates that a standalone list of domain objects (each represented by a xref:refguide:applib:index/services/bookmark/Bookmark.adoc[Bookmark] has been rendered.
--
<.> xref:#onRenderedValue_Object[onRenderedValue(Object)]
+
--
Indicates that a value has been rendered.
--

== Members

[#onRendering_PageType]
=== onRendering(PageType)

Called just before the rendering process starts.However, if _PageType#OTHER_ , then *NO*  `onRenderedXxx` method will be called.

Determines which of the `onRenderedXxx` callbacks (if any) will next be called:

* if _PageType#DOMAIN_OBJECT_ , then will call _#onRenderedDomainObject(Bookmark)_ next
* if _PageType#COLLECTION_ , then will call _#onRenderedCollection(Supplier)_ next
* if _PageType#VALUE_ , then will call _#onRenderedValue(Object)_ next

Also, if any of the pages fail to render (eg due to an authorization exception), then - again - *NO*  `onRenderedXxx` method will be called

Implementations could use this to start a stopwatch, for example, or to reset caches.

[#onRenderedDomainObject_Bookmark]
=== onRenderedDomainObject(Bookmark)

Indicates that the domain object represented by the xref:refguide:applib:index/services/bookmark/Bookmark.adoc[Bookmark] has been rendered.

[#onRenderedCollection_Supplier]
=== onRenderedCollection(Supplier)

Indicates that a standalone list of domain objects (each represented by a xref:refguide:applib:index/services/bookmark/Bookmark.adoc[Bookmark] has been rendered.

[#onRenderedValue_Object]
=== onRenderedValue(Object)

Indicates that a value has been rendered.
