Skip to content

Instantly share code, notes, and snippets.

@steinermatt
Created September 14, 2013 16:16
Show Gist options
  • Save steinermatt/6563271 to your computer and use it in GitHub Desktop.
Save steinermatt/6563271 to your computer and use it in GitHub Desktop.
pjax-tiles / src / main / java / net / inscope / sandbox / pjax / web / PJAXViewPreparer.java
package net.inscope.sandbox.pjax.web;
import org.apache.tiles.Attribute;
import org.apache.tiles.AttributeContext;
import org.apache.tiles.context.TilesRequestContext;
import org.apache.tiles.preparer.PreparerException;
import org.apache.tiles.preparer.ViewPreparer;
public class PJAXViewPreparer implements ViewPreparer
{
public void execute(TilesRequestContext tilesContext, AttributeContext attributeContext) throws PreparerException
{
if (tilesContext.getHeader().containsKey("x-pjax"))
{
Attribute template = attributeContext.getTemplateAttribute();
String templatePath = (String) template.getValue();
templatePath = templatePath.replace("default", "pjax");
template.setValue(templatePath);
attributeContext.setTemplateAttribute(template);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment