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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations