use of org.apache.wicket.settings.PageSettings in project wicket by apache.
the class PageExpirationRecoveryTest method cannotExecuteListener.
@Test
public void cannotExecuteListener() {
PageSettings pageSettings = tester.getApplication().getPageSettings();
// CAN recreate
pageSettings.setRecreateBookmarkablePagesAfterExpiry(true);
// CANNOT execute listener interfaces
pageSettings.setCallListenerAfterExpiry(false);
ExpirationRecoveryPage page = tester.startPage(ExpirationRecoveryPage.class, parameters);
assertEquals(parameters, page.getPageParameters());
tester.getSession().invalidateNow();
assertFalse(page.linkClicked.get());
tester.clickLink("link", false);
page = (ExpirationRecoveryPage) tester.getLastRenderedPage();
// the page is properly recreated
assertEquals("PageParameters should be preserved", parameters, page.getPageParameters());
// but the listener interface is not executed
assertFalse("Link should not be clicked!", page.linkClicked.get());
tester.getSession().invalidateNow();
assertFalse(page.ajaxLinkClicked.get());
tester.clickLink("alink", true);
page = (ExpirationRecoveryPage) tester.getLastRenderedPage();
assertFalse("AjaxLink should not be clicked!", page.ajaxLinkClicked.get());
assertEquals("PageParameters should be preserved", parameters, page.getPageParameters());
tester.getSession().invalidateNow();
assertFalse(page.submitLinkSubmitted.get());
tester.clickLink("f:sl", false);
page = (ExpirationRecoveryPage) tester.getLastRenderedPage();
assertFalse("SubmitLink should not be submitted!", page.submitLinkSubmitted.get());
assertEquals("PageParameters should be preserved", parameters, page.getPageParameters());
tester.getSession().invalidateNow();
assertFalse(page.ajaxSubmitLinkSubmitted.get());
tester.clickLink("f:asl", true);
page = (ExpirationRecoveryPage) tester.getLastRenderedPage();
assertFalse("AjaxSubmitLink should not be submitted", page.ajaxSubmitLinkSubmitted.get());
assertEquals("PageParameters should be preserved", parameters, page.getPageParameters());
tester.getSession().invalidateNow();
assertFalse(page.formSubmitted.get());
String textOldValue = page.textModel.getObject();
FormTester formTester = tester.newFormTester("f");
formTester.setValue("text", "newValue");
formTester.submit();
page = (ExpirationRecoveryPage) tester.getLastRenderedPage();
assertFalse("Form should not be submitted", page.formSubmitted.get());
assertEquals("TextField's value should not be modified", textOldValue, page.textModel.getObject());
assertEquals("PageParameters should be preserved", parameters, page.getPageParameters());
}
use of org.apache.wicket.settings.PageSettings in project wicket by apache.
the class PageExpirationRecoveryTest method cannotRecreatePageShouldThrowPEE.
@Test(expected = PageExpiredException.class)
public void cannotRecreatePageShouldThrowPEE() {
PageSettings pageSettings = tester.getApplication().getPageSettings();
// CANNOT recreate
pageSettings.setRecreateBookmarkablePagesAfterExpiry(false);
ExpirationRecoveryPage page = tester.startPage(ExpirationRecoveryPage.class, parameters);
assertEquals(parameters, page.getPageParameters());
tester.getSession().invalidateNow();
assertFalse(page.linkClicked.get());
// leads to PageExpiredException
tester.clickLink("link", false);
}
use of org.apache.wicket.settings.PageSettings in project wicket by apache.
the class PageExpirationRecoveryTest method canExecuteListener.
@Test
public void canExecuteListener() {
PageSettings pageSettings = tester.getApplication().getPageSettings();
pageSettings.setCallListenerAfterExpiry(true);
pageSettings.setRecreateBookmarkablePagesAfterExpiry(true);
ExpirationRecoveryPage page = tester.startPage(ExpirationRecoveryPage.class, parameters);
assertThat(parameters, is(equalTo(page.getPageParameters())));
tester.getSession().invalidateNow();
assertFalse(page.linkClicked.get());
tester.clickLink("link", false);
page = (ExpirationRecoveryPage) tester.getLastRenderedPage();
assertTrue("Link should be clicked!", page.linkClicked.get());
assertEquals("PageParameters should be preserved", parameters, page.getPageParameters());
tester.getSession().invalidateNow();
assertFalse(page.ajaxLinkClicked.get());
tester.clickLink("alink", true);
page = (ExpirationRecoveryPage) tester.getLastRenderedPage();
assertTrue("AjaxLink should be clicked!", page.ajaxLinkClicked.get());
assertEquals("PageParameters should be preserved", parameters, page.getPageParameters());
tester.getSession().invalidateNow();
assertFalse(page.formSubmitted.get());
FormTester formTester = tester.newFormTester("f");
String newValue = "newValue";
formTester.setValue("text", newValue);
formTester.submit();
page = (ExpirationRecoveryPage) tester.getLastRenderedPage();
assertTrue("Form should be submitted", page.formSubmitted.get());
assertEquals("TextField's value should be modified", newValue, page.textModel.getObject());
assertEquals("PageParameters should be preserved", parameters, page.getPageParameters());
tester.getSession().invalidateNow();
assertFalse(page.submitLinkSubmitted.get());
tester.clickLink("f:sl", false);
page = (ExpirationRecoveryPage) tester.getLastRenderedPage();
assertTrue("SubmitLink should be submitted!", page.submitLinkSubmitted.get());
assertEquals("PageParameters should be preserved", parameters, page.getPageParameters());
tester.getSession().invalidateNow();
assertFalse(page.ajaxSubmitLinkSubmitted.get());
tester.clickLink("f:asl", true);
page = (ExpirationRecoveryPage) tester.getLastRenderedPage();
assertTrue("AjaxSubmitLink should be submitted", page.ajaxSubmitLinkSubmitted.get());
assertEquals("PageParameters should be preserved", parameters, page.getPageParameters());
}
use of org.apache.wicket.settings.PageSettings in project wicket by apache.
the class Application method internalInit.
/**
* THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT OVERRIDE OR CALL.
*
* Internal initialization.
*/
protected void internalInit() {
settingsAccessible = true;
PageSettings pageSettings = getPageSettings();
// Install default component resolvers
pageSettings.addComponentResolver(new HtmlHeaderResolver());
pageSettings.addComponentResolver(new WicketLinkTagHandler());
pageSettings.addComponentResolver(new WicketMessageResolver());
pageSettings.addComponentResolver(new RelativePathPrefixHandler());
pageSettings.addComponentResolver(new EnclosureHandler());
pageSettings.addComponentResolver(new InlineEnclosureHandler());
pageSettings.addComponentResolver(new WicketMessageTagHandler());
pageSettings.addComponentResolver(new WicketContainerResolver());
getResourceSettings().getResourceFinders().add(new ClassPathResourceFinder(""));
// Install button image resource factory
getResourceSettings().addResourceFactory("buttonFactory", new DefaultButtonImageResourceFactory());
String applicationKey = getApplicationKey();
applicationKeyToApplication.put(applicationKey, this);
converterLocator = newConverterLocator();
setPageManagerProvider(new DefaultPageManagerProvider(this));
resourceReferenceRegistry = newResourceReferenceRegistry();
sharedResources = newSharedResources(resourceReferenceRegistry);
resourceBundles = newResourceBundles(resourceReferenceRegistry);
// set up default request mapper
setRootRequestMapper(new SystemMapper(this));
pageFactory = newPageFactory();
requestCycleProvider = (context) -> new RequestCycle(context);
exceptionMapperProvider = () -> new DefaultExceptionMapper();
// add a request cycle listener that logs each request for the requestlogger.
getRequestCycleListeners().add(new RequestLoggerRequestCycleListener());
}
Aggregations