Event Handling Flashcards

1
Q

Event Handling

A

Flow passes user interaction back to the server side as component events. The application can handle these events in Java code using an event handler.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Event Listener

A

Lambda expressions are the easy way in Java to implement interfaces that only have a single method to implement, which is the case with event listeners.
Button button = new Button(“Click me!”,
event -> event.getSource().setText(“Clicked!!!”));
add(button);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Handler Methods

A

You can also direct events to methods with method references:

class ButtonBar extends HorizontalLayout {
public ButtonBar() {
add(new Button(“OK”, this::ok));
add(new Button(“Cancel”, this::cancel));
}

public void ok(ClickEvent<Button> event) {
    event.getSource().setText("OKed!");
}

public void cancel(ClickEvent<Button> event) {
    event.getSource().setText("Canceled!");
} }

add(new ButtonBar());

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Main View

A

The main view itself doesn’t have a route, as it’s only a frame for the actual content views.
A main view uses AppLayout by extending it and setting up the elements in the constructor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Creating Header

A

The navigation bar of AppLayout is a horizontal element that can contain any component, such as a header or a horizontal menu.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly