Application Framework

Headline

For every sheet it is useful to have a headline that describes the current content. It natively has a headline caption and could be extended by subclasses.

create report simple

UIHeadline

You can use @UIHeadline to create a Headline, which comes in two variations:

UIHeadline with only a title

If your headline should only consist of a title, then you can use UIHeadline and return the title as a String.

UIHeadline with String as return type
@UIHeadline(position=10)
public String getHeadlineText() {
    return "MyHeadline";
}
UIHeadline with additional components

If you need to add additional components to the title or the end of the headline, you may also return a HeadlinePmo in the annotated method. A headline PMO consists of a title and two optional PMOs that define the additional components.

UIHeadline with additional components
public void initializeHeadlinePmo() {
    this.headlinePmo = new HeadlinePmo("MyHeadline", new TitleComponentPmo(), new HeadlineEndPmo());
}

@UIHeadline(position=10)
public HeadlinePmo getHeadlinePmo() {
    return this.headlinePmo;
}

Note that the additional PMOs are only evaluated initially. Thus, the PMO instance must remain the same to avoid confusions.

Toggle the visibility of components that are only available conditionally.

Alternatively, HeadlinePmo itself is annotated with a linkki annotation which makes it usable with VaadinUiCreator#createComponent. The created Headline can then be added to any Vaadin layout.

HeadlinePmo with VaadinUiCreator
VaadinUiCreator.createComponent(new HeadlinePmo("MyHeadline", new TitleComponentPmo(), new HeadlineEndPmo()), new BindingContext());

Headline Component

Alternatively, you can directly instantiate Headline and add the component to your content.

If you want the Headline’s title to be updated dynamically, you can also bind it to a PMO. To do so, create a PMO containing a corresponding getter method for Headline#HEADER_TITLE:

public class HeadlinePmo {

    private List<Report> reports;

    public HeadlinePmo(List<Report> reports) {
        this.reports = reports;
    }

    public String getHeaderTitle() {
        return "Report List - Existing reports: " + reports.size();
    }
}

Then bind it with the headline:

        new Binder(headline, headlinePmo).setupBindings(getBindingContext());

To add additional components into the <h2> element holding the title, Headline provides the method addToTitle(Component). Components added via addToTitle() remain present when the title text is updated using setTitle(). Headline uses CompositeH2 internally, which in contrast to H2 preserves children when setting the text. However, Headline can also be initialized with a standard H2 element if needed.