The Vaadin UI

VaadinServlet is configured in the WebConfig class. The UI implementation is realized in the VaadinUI class. For reference, the following is the implementation of the VaadinUI class:

@Title("Call Browser")
public class VaadinUI extends UI {

@Override
protected void init(VaadinRequest vaadinRequest) {
VerticalLayout mainLayout = new VerticalLayout();
mainLayout.addComponentsAndExpand(new CallsBrowser());
setContent(mainLayout);
}
}

Notice how the UI consists of a VerticalLayout that contains only a CallsBrowser component. We'll start with the following implementation of the CallsBrowser custom component:

public class CallsBrowser extends Composite {

public CallsBrowser() {
TextField filter = new TextField();
filter.setPlaceholder("Client / Phone / City");
filter.focus();

Button search = new Button(VaadinIcons.SEARCH);
search.setClickShortcut(ShortcutAction.KeyCode.ENTER);

Button clear = new Button(VaadinIcons.CLOSE_SMALL);

CssLayout filterLayout = new CssLayout(filter, search, clear);
filterLayout.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);

Label countLabel = new Label();
countLabel.addStyleNames(
ValoTheme.LABEL_LIGHT, ValoTheme.LABEL_SMALL);

HorizontalLayout headerLayout = new HorizontalLayout(
filterLayout, countLabel);
headerLayout.setComponentAlignment(countLabel, Alignment.MIDDLE_LEFT);

Grid<Call> grid = new Grid<>(Call.class);
grid.setColumns("id", "client", "phoneNumber", "city", "startTime",
"duration", "status");
grid.setSizeFull();

VerticalLayout mainLayout = new VerticalLayout(headerLayout);
mainLayout.setMargin(false);
mainLayout.addComponentsAndExpand(grid);
setCompositionRoot(mainLayout);
}
}

The previous class can be used as a starting point if you want to implement the concepts of this chapter yourself. At this point, the UI doesn't show any data in the Grid and it has no behavior.

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

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