The Vaadin UI

The VaadinServlet is configured in the WebConfig class. The UI implementation is realized in the VaadinUI class. For reference, the following snippet of code shows the implementation of the layout of the example application:

@Title("Report Viewer")
public class VaadinUI extends UI {

private HorizontalLayout header = new HorizontalLayout();
private Panel panel = new Panel();
private MenuBar.MenuItem annualLegalReportItem;

@Override
protected void init(VaadinRequest vaadinRequest) {
MenuBar menuBar = new MenuBar();
menuBar.addStyleName(ValoTheme.MENUBAR_BORDERLESS);
MenuBar.MenuItem reportsMenuItem = menuBar.addItem("Reports", VaadinIcons.FILE_TABLE, null);
reportsMenuItem.addItem("Worldwide Calls in the Last Hour", VaadinIcons.PHONE_LANDLINE,
i -> showLastHourCallReport());
reportsMenuItem.addItem("Monthly Capacity Report", VaadinIcons.BAR_CHART_H,
i -> showMonthlyCapacityReport());
annualLegalReportItem = reportsMenuItem.addItem("Annual Legal Report", VaadinIcons.FILE_TEXT_O,
i -> generateAnnualLegalReport());

header.addComponents(menuBar);

panel.addStyleName(ValoTheme.PANEL_WELL);

VerticalLayout mainLayout = new VerticalLayout(header);
mainLayout.addComponentsAndExpand(panel);
setContent(mainLayout);
}
...
}

We are going to develop three different reports. The showLastHourCallReport, showMonthlyCapacityReport, and generateAnnualLegalReport methods include the logic to modify the UI in order to show the respective report inside the panel component.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset