Skip to content

Instantly share code, notes, and snippets.

@killertilapia
Created April 28, 2016 00:31
Show Gist options
  • Save killertilapia/b2509b6721d14e2abc5dd8cc1eda571d to your computer and use it in GitHub Desktop.
Save killertilapia/b2509b6721d14e2abc5dd8cc1eda571d to your computer and use it in GitHub Desktop.
Tapestry5 layout with DataTable and Patternfly imports
package cu.ictso.miscapps.components;
import cu.ictso.miscapps.pages.Index;
import org.apache.shiro.subject.Subject;
import org.apache.tapestry5.*;
import org.apache.tapestry5.annotations.*;
import org.apache.tapestry5.ioc.annotations.*;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.SymbolConstants;
import org.tynamo.security.services.SecurityService;
/**
* Layout component
*/
@Import(module = {"bootstrap/collapse"},
stylesheet = {"context:datatables/css/dataTables.jqueryui.css","context:patternfly/css/patternfly.css",
"context:patternfly/css/patternfly-additions.css"},
library = {"context:patternfly/js/patternfly.js", "context:mybootstrap/js/bootstrap.js"})
public class Layout {
@Inject
private ComponentResources resources;
@Inject
private SecurityService securityService;
/**
* The page title, for the <title> element and the <h1> element.
*/
@Property
@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
private String title;
@Property
@Parameter(required = false, defaultPrefix = BindingConstants.LITERAL)
private String pageName;
@Property
@Parameter(defaultPrefix = BindingConstants.LITERAL)
private Block navbar;
@Property
@Inject
@Symbol(SymbolConstants.APPLICATION_VERSION)
private String appVersion;
public String getClassForPageName() {
return resources.getPageName().equalsIgnoreCase(pageName)
? "active"
: null;
}
public String getLoggedUsername(){
Subject currentUser = securityService.getSubject();
return (String) currentUser.getPrincipal();
}
public Object onSignOut(){
Subject currentUser = securityService.getSubject();
currentUser.logout();
return Index.class;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment