+ All Categories
Home > Presentations & Public Speaking > Building impressive layout systems with vaadin

Building impressive layout systems with vaadin

Date post: 22-Jan-2018
Category:
Upload: peter-lehto
View: 958 times
Download: 1 times
Share this document with a friend
104
Building impressive layout systems for mobile, desktop and tablet Peter Lehto Senior Vaadin Expert @peter_lehto
Transcript
Page 1: Building impressive layout systems with vaadin

Building impressive layout systems

for mobile, desktop and tablet

Peter Lehto Senior Vaadin Expert

@peter_lehto

Page 2: Building impressive layout systems with vaadin

Setting up UI

Navigation

system

Page 3: Building impressive layout systems with vaadin

Application views

Responsive

menu

Page 4: Building impressive layout systems with vaadin

QAEvents and

Security

Page 5: Building impressive layout systems with vaadin

Setting up UI

Page 6: Building impressive layout systems with vaadin

github.com/peterl1084/devday2016

Page 7: Building impressive layout systems with vaadin

public class DevDayUI extends UI {

}

Page 8: Building impressive layout systems with vaadin

@CDIUI("")public class DevDayUI extends UI {

}

Page 9: Building impressive layout systems with vaadin

@CDIUI("")public class DevDayUI extends UI {

@Injectprivate ViewDisplay viewDisplay;

@Overrideprotected void init(VaadinRequest request) {

…setContent((Component)viewDisplay);

}}

Page 10: Building impressive layout systems with vaadin

UI as Bean

Page 11: Building impressive layout systems with vaadin

Entry point

UI as Bean

Page 12: Building impressive layout systems with vaadin

Entry point

Context aware

UI as Bean

Page 13: Building impressive layout systems with vaadin

Entry point

Context aware

Accesible through URI

UI as Bean

Page 14: Building impressive layout systems with vaadin

Entry point

Context aware

Accesible through URI

CDI / Spring Beans (with @SpringUI)

UI as Bean

Page 15: Building impressive layout systems with vaadin

@CDIUI("")public class DevDayUI extends UI {

@Injectprivate ViewDisplay viewDisplay;

@Overrideprotected void init(VaadinRequest request) {

…setContent((Component)viewDisplay);

}}

Page 16: Building impressive layout systems with vaadin

@CDIUI("anotherUI")public class DevDayUI extends UI {

@Injectprivate ViewDisplay viewDisplay;

@Overrideprotected void init(VaadinRequest request) {

…setContent((Component)viewDisplay);

}}

Page 17: Building impressive layout systems with vaadin

http://localhost:8080/app/

http://localhost:8080/app/anotherUI

app: contextanotherUI : UI name

Page 18: Building impressive layout systems with vaadin

HorizontalLayout

Page 19: Building impressive layout systems with vaadin

HorizontalLayoutMenu

Page 20: Building impressive layout systems with vaadin

HorizontalLayoutContentAreaMenu

Page 21: Building impressive layout systems with vaadin

Navigation

Page 22: Building impressive layout systems with vaadin

public interface NavigationManager {

void navigateTo(String viewId);

View getCurrentView();}

Page 23: Building impressive layout systems with vaadin

public class NavigationManagerBean

Page 24: Building impressive layout systems with vaadin

public class NavigationManagerBean extends Navigator implements NavigationManager {

Page 25: Building impressive layout systems with vaadin

public class NavigationManagerBean extends Navigator implements NavigationManager {

@Injectprivate ViewDisplay viewDisplay;

…}

Page 26: Building impressive layout systems with vaadin

ViewDisplay

Page 27: Building impressive layout systems with vaadin

Structure ‘content area’ with components

ViewDisplay

Page 28: Building impressive layout systems with vaadin

Structure ‘content area’ with components

Access view before it’s shown

ViewDisplay

Page 29: Building impressive layout systems with vaadin

Structure ‘content area’ with components

Access view before it’s shown

Various framework implementations

ViewDisplay

Page 30: Building impressive layout systems with vaadin

public class NavigationManagerBean extends Navigator implements NavigationManager {

@Injectprivate ViewDisplay viewDisplay;

@Injectprivate CDIViewProvider viewProvider;

…}

Page 31: Building impressive layout systems with vaadin

CDIViewProvider

Page 32: Building impressive layout systems with vaadin

View Bean discovery

CDIViewProvider

Page 33: Building impressive layout systems with vaadin

View Bean discovery

Access control per view

CDIViewProvider

Page 34: Building impressive layout systems with vaadin

View Bean discovery

Access control per view

SpringViewProvider for Spring Beans

CDIViewProvider

Page 35: Building impressive layout systems with vaadin

public class NavigationManagerBean extends Navigator implements NavigationManager {

@Injectprivate ViewDisplay viewDisplay;

@Injectprivate CDIViewProvider viewProvider;

@Injectprivate ViewChangeListener viewChangeListener;

…}

Page 36: Building impressive layout systems with vaadin

ViewChangeListener

Page 37: Building impressive layout systems with vaadin

Before and AfterViewChange events

ViewChangeListener

Page 38: Building impressive layout systems with vaadin

Before and AfterViewChange events

Ability to cancel navigation

ViewChangeListener

Page 39: Building impressive layout systems with vaadin

Scope UI specific beans with

@UIScoped

Page 40: Building impressive layout systems with vaadin

@UIScopedpublic class ValoMainMenuBean extends CssLayout implements MainMenu

Page 41: Building impressive layout systems with vaadin

@UIScoped

Page 42: Building impressive layout systems with vaadin

Bean associated with UI instance

@UIScoped

Page 43: Building impressive layout systems with vaadin

Bean associated with UI instance

Bean associated with Web browser tab

@UIScoped

Page 44: Building impressive layout systems with vaadin

Bean associated with UI instance

Bean associated with Web browser tab

@CDIUI is by default @UIScoped

@UIScoped

Page 45: Building impressive layout systems with vaadin

@CDIUI DevDayUI

_____________________________

@Injectprivate ViewDisplay menu;

@Injectprivate User currentUser;

@UIScoped

DevDayUIViewDisplay

@SessionScoped

User

Page 46: Building impressive layout systems with vaadin

@SessionScoped

User

@CDIUI DevDayUI

_____________________________

@Injectprivate ViewDisplay menu;

@Injectprivate User currentUser;

@UIScoped

DevDayUIViewDisplay

@CDIUI DevDayUI

_____________________________

@Injectprivate ViewDisplay menu;

@Injectprivate User currentUser;

@UIScoped

DevDayUIViewDisplay

@CDIUI DevDayUI

_____________________________

@Injectprivate ViewDisplay menu;

@Injectprivate User currentUser;

@UIScoped

DevDayUIViewDisplay

Page 47: Building impressive layout systems with vaadin

What about Views?

Page 48: Building impressive layout systems with vaadin

View

Page 49: Building impressive layout systems with vaadin

Component composition

View

Page 50: Building impressive layout systems with vaadin

Component composition

Active view switched by Navigator

View

Page 51: Building impressive layout systems with vaadin

Component composition

Active view switched by Navigator

Positioned inside ViewDisplay

View

Page 52: Building impressive layout systems with vaadin

HorizontalLayoutContentAreaMenu

View1

View2

View3

Page 53: Building impressive layout systems with vaadin

HorizontalLayoutView1Menu

View1

View2

View3

Page 54: Building impressive layout systems with vaadin

HorizontalLayoutView2Menu

View1

View2

View3

Page 55: Building impressive layout systems with vaadin

HorizontalLayoutView3Menu

View1

View2

View3

Page 56: Building impressive layout systems with vaadin

View as bean with

@CDIView

Page 57: Building impressive layout systems with vaadin

public class CustomerViewBean

Page 58: Building impressive layout systems with vaadin

public class CustomerViewBean extends VerticalLayout

Page 59: Building impressive layout systems with vaadin

@CDIView("customers")public class CustomerViewBean extends VerticalLayout implements View

Page 60: Building impressive layout systems with vaadin

http://localhost:8080/app/#!customers

#! : Navigator identifiercustomers : View name

Page 61: Building impressive layout systems with vaadin

Scope View specific beans with

@ViewScoped

Page 62: Building impressive layout systems with vaadin

@ViewScoped

Page 63: Building impressive layout systems with vaadin

Beans associated with View

@ViewScoped

Page 64: Building impressive layout systems with vaadin

Beans associated with View

@CDIView by default @ViewScoped

@ViewScoped

Page 65: Building impressive layout systems with vaadin

Beans associated with View

@CDIView by default @ViewScoped

@SpringView for Spring Beans

@ViewScoped

Page 66: Building impressive layout systems with vaadin

@ApplicationScoped

Page 67: Building impressive layout systems with vaadin

@ApplicationScoped@SessionScoped

Page 68: Building impressive layout systems with vaadin

@ApplicationScoped@SessionScoped

@UIScoped

Page 69: Building impressive layout systems with vaadin

@ApplicationScoped@SessionScoped

@UIScoped @ViewScoped

Page 70: Building impressive layout systems with vaadin

@ApplicationScoped

Page 71: Building impressive layout systems with vaadin

@ApplicationScoped@ApplicationScoped

@SessionScoped @SessionScoped @SessionScoped

Page 72: Building impressive layout systems with vaadin

@ApplicationScoped

@SessionScoped @SessionScoped @SessionScoped

@UI Scoped

@UI Scoped

@UI Scoped

@UI Scoped

@UI Scoped

@UI Scoped

Page 73: Building impressive layout systems with vaadin

@ApplicationScoped

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@SessionScoped @SessionScoped @SessionScoped

@UI Scoped

@UI Scoped

@UI Scoped

@UI Scoped

@UI Scoped

@UI Scoped

Page 74: Building impressive layout systems with vaadin

Responsive UI

Page 75: Building impressive layout systems with vaadin

HorizontalLayoutContentAreaMenu

Page 76: Building impressive layout systems with vaadin

HorizontalLayoutContentAreaMenu

Page 77: Building impressive layout systems with vaadin

HorizontalLayoutContentArea

Menu

Page 78: Building impressive layout systems with vaadin

HorizontalLayoutContentArea

Page 79: Building impressive layout systems with vaadin

Responsive

Page 80: Building impressive layout systems with vaadin

Extension in Vaadin since 7.2

Responsive

Page 81: Building impressive layout systems with vaadin

Extension in Vaadin since 7.2

Relatively sized host component

Responsive

Page 82: Building impressive layout systems with vaadin

Extension in Vaadin since 7.2

Relatively sized host component

Pixel specified ranges

Responsive

Page 83: Building impressive layout systems with vaadin

CssLayout layout = new CssLayout();layout.setStyleName("responsive");layout.setSizeFull();Responsive.makeResponsive(layout);

Page 84: Building impressive layout systems with vaadin
Page 85: Building impressive layout systems with vaadin

ValoMenu

Page 86: Building impressive layout systems with vaadin

Set of styles in Valo Theme

ValoMenu

Page 87: Building impressive layout systems with vaadin

Set of styles in Valo Theme

No framework level API available

ValoMenu

Page 88: Building impressive layout systems with vaadin

Set of styles in Valo Theme

No framework level API available

Live example provided in DevDay App(See ValoMainMenuBean)

ValoMenu

Page 89: Building impressive layout systems with vaadin

Events and busses with

Event<MyEvent>

Page 90: Building impressive layout systems with vaadin

@UIScopedpublic class MainMenuBean extends VerticalLayout {

@Injectprivate Event<NavigationEvent> eventSource;

protected void onMenuItemClicked(MenuItem item) {eventSource.fireEvent(new NavigationEvent(item));

}}

Page 91: Building impressive layout systems with vaadin

@UIScopedpublic class NavigationManager {

private void onNavigationEvent(@ObservesNavigationEvent e) {

getNavigator().navigateTo(e.getView().getId());}

}

Page 92: Building impressive layout systems with vaadin

@ApplicationScoped

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@ View

@SessionScoped @SessionScoped @SessionScoped

@UI Scoped

@UI Scoped

@UI Scoped

@UI Scoped

@UI Scoped

@UI Scoped

Page 93: Building impressive layout systems with vaadin

Security with

Access control

Page 94: Building impressive layout systems with vaadin

CDIViewProvider

Page 95: Building impressive layout systems with vaadin

isUserHavingAccessToView

CDIViewProvider

Page 96: Building impressive layout systems with vaadin

isUserHavingAccessToView

@RolesAllowed for static role def

CDIViewProvider

Page 97: Building impressive layout systems with vaadin

isUserHavingAccessToView

@RolesAllowed for static role def

com.vaadin.cdi.AccessControl

CDIViewProvider

Page 98: Building impressive layout systems with vaadin

isUserHavingAccessToView

@RolesAllowed for static role def

com.vaadin.cdi.AccessControl

Default JAAS implementation

CDIViewProvider

Page 99: Building impressive layout systems with vaadin

Lessons learned

Page 100: Building impressive layout systems with vaadin

Lessons learned

1. Bean based UIs provide easier enterprise integration

Page 101: Building impressive layout systems with vaadin

Lessons learned

1. Bean based UIs provide easier enterprise integration

2. Official support for CDI and SpringBeans

Page 102: Building impressive layout systems with vaadin

Lessons learned

1. Bean based UIs provide easier enterprise integration

2. Official support for CDI and SpringBeans

3. Navigator with utility API make navigation simple

Page 103: Building impressive layout systems with vaadin

Lessons learned

1. Bean based UIs provide easier enterprise integration

2. Official support for CDI and SpringBeans

3. Navigator with utility API make navigation simple

4. Responsive addon integrated to core with Valo theme

Page 104: Building impressive layout systems with vaadin

Lessons learned

1. Bean based UIs provide easier enterprise integration

2. Official support for CDI and SpringBeans

3. Navigator with utility API make navigation simple

4. Responsive addon integrated to core with Valo theme

5. Events provide loose coupling with scopes as borders


Recommended