Created
December 21, 2012 12:46
-
-
Save anonymous/4352582 to your computer and use it in GitHub Desktop.
SiteMesh3 configuation example, showing custom decorator selector based on HttpSession.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyCustomDecoratorSelector extends DecoratorSelector<WebAppContext> { | |
@Override | |
public String[] selectDecoratorPaths(Content content, WebAppContext context) throws IOException { | |
HttpServletRequest request = context.getRequest(); | |
if (request.getSession().getValue("is_admin") != null) { | |
return new String[] {"/decorators/admin-decorator.html"}; | |
} else { | |
return new String[] {"/decorators/normal-decorator.html"}; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyCustomSiteMeshFilter extends ConfigurableSiteMeshFilter { | |
@Override | |
protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) { | |
builder.setCustomDecoratorSelector(new MyCustomDecoratorSelector()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<web-app> | |
<filter> | |
<filter-name>sitemesh</filter-name> | |
<filter-class>com.blah.MyCustomSiteMeshFilter</filter-class> | |
</filter> | |
<filter-mapping> | |
<filter-name>sitemesh</filter-name> | |
<url-pattern>/*</url-pattern> | |
</filter-mapping> | |
</web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment