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

Provides the ability to load the XML layout (grid) for a domain class.

== API

[source,java]
.GridLoaderService.java
----
interface GridLoaderService {
  boolean supportsReloading()     // <.>
  void remove(Class<?> domainClass)     // <.>
  boolean existsFor(Class<?> domainClass)     // <.>
  Grid load(Class<?> domainClass)     // <.>
  Grid load(Class<?> domainClass, String layout)     // <.>
}
----

<.> xref:#supportsReloading_[supportsReloading()]
+
--
Whether dynamic reloading of layouts is enabled.
--
<.> xref:#remove_Class[remove(Class)]
+
--
To support metamodel invalidation/rebuilding of spec.
--
<.> xref:#existsFor_Class[existsFor(Class)]
+
--
Whether any persisted layout metadata (eg a `.layout.xml` file) exists for this domain class.
--
<.> xref:#load_Class[load(Class)]
+
--
Returns a new instance of a xref:refguide:applib:index/layout/grid/Grid.adoc[Grid] for the specified domain class, eg from a `layout.xml` file, else `null` .
--
<.> xref:#load_Class_String[load(Class, String)]
+
--
Loads a specic alternative xref:refguide:applib:index/layout/grid/Grid.adoc[Grid] layout for the specified domain class.
--

== Members

[#supportsReloading_]
=== supportsReloading()

Whether dynamic reloading of layouts is enabled.

The default implementation enables reloading for prototyping mode, disables in production

[#remove_Class]
=== remove(Class)

To support metamodel invalidation/rebuilding of spec.

This is called by the xref:refguide:applib:index/mixins/metamodel/Object_rebuildMetamodel.adoc[Object_rebuildMetamodel] mixin action.

[#existsFor_Class]
=== existsFor(Class)

Whether any persisted layout metadata (eg a `.layout.xml` file) exists for this domain class.

If none exists, will return null (and the calling xref:refguide:applib:index/services/grid/GridService.adoc[GridService] will use xref:refguide:applib:index/services/grid/GridSystemService.adoc[GridSystemService] to obtain a default grid for the domain class).

[#load_Class]
=== load(Class)

Returns a new instance of a xref:refguide:applib:index/layout/grid/Grid.adoc[Grid] for the specified domain class, eg from a `layout.xml` file, else `null` .

[#load_Class_String]
=== load(Class, String)

Loads a specic alternative xref:refguide:applib:index/layout/grid/Grid.adoc[Grid] layout for the specified domain class.

The layout alternative will typically be specified through a `layout()` method on the domain object, the value of which is used for the suffix of the layout file (eg "Customer-layout.archived.xml" to use a different layout for customers that have been archived).

include::hooks/GridLoaderService_010-implementation.adoc[]

include::hooks/GridLoaderService_020-examples-and-usage.adoc[]
