public void setHeaders(WebPage aPage, WebResponse aResponse) {
// Empty
}
-
+
@Override
public void onAfterRender(WebPage aPage) {
// Empty
}
-
+
@Override
public void onDetach(WebPage aPage) {
- // Empty
+ // Empty
}
}
behavior.setHeaders(aPage, aResponse);
}
}
-
+
@Override
public void onAfterRender(WebPage aPage) {
for (PageBehavior behavior : behaviors) {
behavior.onAfterRender(aPage);
}
}
-
+
@Override
public void onDetach(WebPage aPage) {
for (PageBehavior behavior : behaviors) {
/**
* <p>
- * Behavior to disable browser caching.
+ * Behavior to disable browser caching.
* </p>
*
* <p>
import org.apache.wicket.markup.html.WebPage;
/**
- * Bahevior that will expire a page when the page is disabled.
- * Implementations should implemnet
+ * Bahevior that will expire a page when the page is disabled. Implementations
+ * should implemnet
*
* @author Erik Brakkee
*
*/
public abstract class ExpireBehavior extends AbstractPageBehavior {
- private static final Logger LOGGER = Logger.getLogger(ExpireBehavior.class.getName());
+ private static final Logger LOGGER = Logger.getLogger(ExpireBehavior.class
+ .getName());
/**
* Constructs the behavior.
*/
- public ExpireBehavior() {
+ public ExpireBehavior() {
super();
}
aPage.getPageMap().remove(aPage);
}
}
-
+
/**
* Must be implemented to determine if a page is expired.
- * @param aPage Page to check. If a behavior instance is only used on one page then this
- * argument is always that page so it can bne ignored in that case.
+ *
+ * @param aPage
+ * Page to check. If a behavior instance is only used on one page
+ * then this argument is always that page so it can bne ignored
+ * in that case.
* @return
*/
- protected abstract boolean isExpired(WebPage aPage);
-
+ protected abstract boolean isExpired(WebPage aPage);
+
}
/**
* Page which will be removed from the page map after rendering so it can be
- * viewed only once. Even a refresh of the page will fail.
+ * viewed only once. Even a refresh of the page will fail.
*
* @author Erik Brakkee
*
LOGGER.log(Level.WARNING, "Could not flush entitymanager", e);
}
}
-
+
/**
* Gets the entity mmanager to flush.
+ *
* @return Entity manager.
*/
public abstract EntityManager getEntityManager();
import org.apache.wicket.protocol.http.WebResponse;
/**
- * Logs page events.
+ * Logs page events.
*
* @author Erik Brakkee
*/
public class LoggingPageBehavior implements PageBehavior {
-
- private static final Logger LOG = Logger.getLogger(LoggingPageBehavior.class.getName());
-
- private Level level;
-
+
+ private static final Logger LOG = Logger
+ .getLogger(LoggingPageBehavior.class.getName());
+
+ private Level level;
+
/**
* Constructs the behavior.
*/
- public LoggingPageBehavior(Level aLevel) {
+ public LoggingPageBehavior(Level aLevel) {
level = aLevel;
}
@Override
public void onBeforeRender(WebPage aPage) {
- LOG.log(level, "onbeforeRender: " + aPage);
+ LOG.log(level, "onbeforeRender: " + aPage);
}
@Override
public void setHeaders(WebPage aPage, WebResponse aResponse) {
- LOG.log(level,"setHeaders: " + aPage + " " + aResponse);
+ LOG.log(level, "setHeaders: " + aPage + " " + aResponse);
}
-
+
@Override
public void onAfterRender(WebPage aPage) {
LOG.log(level, "onAfterRender: " + aPage);
}
-
+
@Override
public void onDetach(WebPage aPage) {
LOG.log(level, "onDetach: " + aPage);
}
-
}
/**
* Page behavior interface. This provides a mechanism to extend page behavior
- * without subclassing. Implementations of this interface should be serializable.
+ * without subclassing. Implementations of this interface should be
+ * serializable.
*
* @author Erik Brakkee
*/
* Page this is called for.
*/
void onAfterRender(WebPage aPage);
-
+
/**
* To be called in the {@link Page#onDetach
+
*/
void onDetach(WebPage aPage);
}
init();
}
- protected WebApplicationBasePage(final IModel<?> model) {
- super(model);
+ protected WebApplicationBasePage(final IModel<?> aModel) {
+ super(aModel);
init();
}
- protected WebApplicationBasePage(final IPageMap pageMap) {
- super(pageMap);
+ protected WebApplicationBasePage(final IPageMap aPageMap) {
+ super(aPageMap);
init();
}
- protected WebApplicationBasePage(final IPageMap pageMap,
- final IModel<?> model) {
- super(pageMap, model);
+ protected WebApplicationBasePage(final IPageMap aPageMap,
+ final IModel<?> aModel) {
+ super(aPageMap, aModel);
init();
}
- protected WebApplicationBasePage(final PageParameters parameters) {
- super(parameters);
+ protected WebApplicationBasePage(final PageParameters aParameters) {
+ super(aParameters);
init();
}
- protected WebApplicationBasePage(final IPageMap pageMap,
- final PageParameters parameters) {
- super(pageMap, parameters);
+ protected WebApplicationBasePage(final IPageMap aPageMap,
+ final PageParameters aParameters) {
+ super(aPageMap, aParameters);
init();
}
public static final class TestPage extends WebApplicationBasePage {
- private WebResponse response;
+ private transient WebResponse response;
public TestPage(WebResponse aResponse) {
response = aResponse;
mock(IPageMap.class), new PageParameters());
final EntityManager entityManager = mock(EntityManager.class);
when(entityManager.isOpen()).thenReturn(true);
- PageBehavior behavior = new FlushEntityManagerBehavior() {
- public EntityManager getEntityManager() { return entityManager; }
+ PageBehavior behavior = new FlushEntityManagerBehavior() {
+ public EntityManager getEntityManager() {
+ return entityManager;
+ }
};
page.addBehavior(behavior);
wicket.startPage(page);