[[titles-in-tables]]
= Titles in Tables

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


Object titles can often be quite long if the intention is to uniquely identify the object.
While this is appropriate for the object view, it can be cumbersome within tables.

If an object's title is specified with from `@Title` annotation then the Wicket viewer will (for parented collections) automatically "contextualize" a title by excluding the part of the title corresponding to a reference to the owning (parent) object.

For example, suppose we have:

[plantuml]
----
hide empty members
class Customer {}
class Order {}
class Product {}

Customer <-d-> "0..*" Order
Product <-d[norank]-> "0..*" Order
----

so that `Customer` has a collection of ``Order``s:

[source,java]
----
public class Customer {
    public Set<Order> getOrders() { /* ... */ }
    ...
}
----

and `Product` also has a collection of ``Order``s:

[source,java]
----
public class Product {
    public Set<Order> getOrders() { /* ... */ }
    ...
}
----

and where the `Order` class references both `Customer` and `Product`.

The ``Order``'s might involve each of these:

[source,java]
----
public class Order {
    @Title(sequence="1")
    public Customer getCustomer() { /* ... */ }
    @Title(sequence="2")
    public Product getProduct() { /* ... */ }
    @Title(sequence="3")
    public String getOtherInfo() { /* ... */ }
    ...
}
----

In this case, if we view a `Customer` with its collection of ``Order``s, then in that parented collection's table the customer's property will be automatically excluded from the title of the `Order` (but it would show the product).
Conversely, if a `Product` is viewed then its collection of ``Order``s would suppress product (but would show the customer).

[TIP]
====
This feature is a close cousin of the `@PropertyLayout(hidden=Where.REFERENCES_PARENT)` annotation, which will cause the property itself to be hidden as a column in the table.
An Apache Causeway idiom is therefore:

[source,java]
----
public class Order {
    @Title(sequence="1")
    @PropertyLayout(hidden=Where.REFERENCES_PARENT)
    public Customer getCustomer() { /* ... */ }
    ...
}
----
====

The above annotations mean that titles usually "just work", altering according to the context in which they are viewed.

[TIP]
====
It is also possible to configure the Wicket viewer to xref:vw:ROOT:setup-and-configuration.adoc#presentation[abbreviate titles or suppress them] completely.
====
