Search in sources :

Example 36 with PostConstruct

use of javax.annotation.PostConstruct in project vaadin-samples by xpoft.

the class RoleAdminView method PostConstruct.

@PostConstruct
public void PostConstruct() {
    setSizeFull();
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.addComponent(new Label("@RequiresRoles(\"admin\")"));
    layout.addComponent(new Link("Go back", new ExternalResource("#!" + MainView.NAME)));
    setContent(layout);
}
Also used : Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) ExternalResource(com.vaadin.server.ExternalResource) Link(com.vaadin.ui.Link) PostConstruct(javax.annotation.PostConstruct)

Example 37 with PostConstruct

use of javax.annotation.PostConstruct in project vaadin-samples by xpoft.

the class RoleUserView method PostConstruct.

@PostConstruct
public void PostConstruct() {
    setSizeFull();
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.addComponent(new Label("@RequiresRoles(\"user\")"));
    layout.addComponent(new Link("Go back", new ExternalResource("#!" + MainView.NAME)));
    setContent(layout);
}
Also used : Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) ExternalResource(com.vaadin.server.ExternalResource) Link(com.vaadin.ui.Link) PostConstruct(javax.annotation.PostConstruct)

Example 38 with PostConstruct

use of javax.annotation.PostConstruct in project vaadin-samples by xpoft.

the class ChooseLanguage method PostConstruct.

@PostConstruct
public void PostConstruct() {
    setCaption(messageSource.getMessage("choose_language.select_lang"));
    setWidth(-1, Unit.PIXELS);
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setWidth(-1, Unit.PIXELS);
    buttons.setSpacing(true);
    Button russian = new Button(messageSource.getMessage("choose_language.russian"), new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().getSession().setLocale(new Locale("ru"));
            // Reload page
            UI.getCurrent().getPage().setUriFragment(UI.getCurrent().getPage().getUriFragment() + "/");
        }
    });
    russian.setIcon(new ExternalResource("static/img/ru_flag.png"));
    buttons.addComponent(russian);
    Button english = new Button(messageSource.getMessage("choose_language.english"), new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().getSession().setLocale(Locale.ENGLISH);
            // Reload page
            UI.getCurrent().getPage().setUriFragment(UI.getCurrent().getPage().getUriFragment() + "/");
        }
    });
    english.setIcon(new ExternalResource("static/img/uk_flag.png"));
    buttons.addComponent(english);
    Button german = new Button(messageSource.getMessage("choose_language.german"), new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().getSession().setLocale(Locale.GERMAN);
            // Reload page
            UI.getCurrent().getPage().setUriFragment(UI.getCurrent().getPage().getUriFragment() + "/");
        }
    });
    german.setIcon(new ExternalResource("static/img/de_flag.png"));
    buttons.addComponent(german);
    Button finnish = new Button(messageSource.getMessage("choose_language.finnish"), new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().getSession().setLocale(new Locale("fi"));
            // Reload page
            UI.getCurrent().getPage().setUriFragment(UI.getCurrent().getPage().getUriFragment() + "/");
        }
    });
    finnish.setIcon(new ExternalResource("static/img/fi_flag.png"));
    buttons.addComponent(finnish);
    setContent(buttons);
}
Also used : Locale(java.util.Locale) Button(com.vaadin.ui.Button) ExternalResource(com.vaadin.server.ExternalResource) HorizontalLayout(com.vaadin.ui.HorizontalLayout) PostConstruct(javax.annotation.PostConstruct)

Example 39 with PostConstruct

use of javax.annotation.PostConstruct in project vaadin-samples by xpoft.

the class MainView method PostConstruct.

@PostConstruct
public void PostConstruct() {
    setSizeFull();
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    HorizontalLayout usernameLayout = new HorizontalLayout();
    usernameLayout.setSpacing(true);
    usernameLayout.addComponent(new Label("Username:"));
    usernameLayout.addComponent(usernameLabel);
    HorizontalLayout userRolesLayout = new HorizontalLayout();
    userRolesLayout.setSpacing(true);
    userRolesLayout.addComponent(new Label("Roles:"));
    userRolesLayout.addComponent(rolesLabel);
    layout.addComponent(usernameLayout);
    layout.addComponent(userRolesLayout);
    Link userView = new Link("ROLE_USER View (disabled, if user doesn't have access)", new ExternalResource("#!" + RoleUserView.NAME));
    Link roleView = new Link("ROLE_ADMIN View (disabled, if user doesn't have access)", new ExternalResource("#!" + RoleAdminView.NAME));
    userView.setEnabled(SpringSecurityHelper.hasRole("ROLE_USER"));
    roleView.setEnabled(SpringSecurityHelper.hasRole("ROLE_ADMIN"));
    layout.addComponent(userView);
    layout.addComponent(roleView);
    layout.addComponent(new Link("ROLE_ADMIN View (throw exception, if user doesn't have access)", new ExternalResource("#!" + RoleAdminView.NAME)));
    layout.addComponent(new Link("Logout", new ExternalResource("/j_spring_security_logout")));
    setContent(layout);
}
Also used : ExternalResource(com.vaadin.server.ExternalResource) PostConstruct(javax.annotation.PostConstruct)

Example 40 with PostConstruct

use of javax.annotation.PostConstruct in project vaadin-samples by xpoft.

the class RoleAdminView method PostConstruct.

@PostConstruct
public void PostConstruct() {
    LoggerFactory.getLogger(this.getClass()).debug("POST");
    setSizeFull();
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.addComponent(new Label("ROLE_ADMIN"));
    layout.addComponent(new Link("Go back", new ExternalResource("#!" + MainView.NAME)));
    setContent(layout);
}
Also used : Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) ExternalResource(com.vaadin.server.ExternalResource) Link(com.vaadin.ui.Link) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)248 IOException (java.io.IOException)28 File (java.io.File)18 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)17 Map (java.util.Map)15 ArrayList (java.util.ArrayList)12 ExternalResource (com.vaadin.server.ExternalResource)11 HashMap (java.util.HashMap)10 InitialContext (javax.naming.InitialContext)9 Label (com.vaadin.ui.Label)8 VerticalLayout (com.vaadin.ui.VerticalLayout)8 Request (com.nabalive.framework.web.Request)7 Response (com.nabalive.framework.web.Response)7 Route (com.nabalive.framework.web.Route)7 Link (com.vaadin.ui.Link)7 Properties (java.util.Properties)7 Method (java.lang.reflect.Method)5 InputStream (java.io.InputStream)4 URISyntaxException (java.net.URISyntaxException)4 Path (java.nio.file.Path)4