use of org.apache.wicket.core.request.mapper.MountedMapper in project wicket by apache.
the class ConversationPropagatorTest method testPropagationAllHybridRefresh.
/**
* https://issues.apache.org/jira/browse/WICKET-6257
*/
@Test
public void testPropagationAllHybridRefresh() {
configure(new CdiConfiguration().setPropagation(ConversationPropagation.ALL));
tester.getApplication().getRootRequestMapperAsCompound().add(new MountedMapper("segment/${pageType}", TestConversationPage.class));
tester.startPage(TestConversationPage.class, new PageParameters().add("pageType", "hybrid"));
String pageId = tester.getLastRenderedPage().getId();
String cid = conversation.getId();
tester.executeUrl("segment/hybrid?" + pageId + "&cid=" + cid);
assertThat(tester.getLastRenderedPage().getId(), CoreMatchers.is(pageId));
}
use of org.apache.wicket.core.request.mapper.MountedMapper in project wicket by apache.
the class RerenderPageTest method wicket5960.
/**
* A testcase for WICKET-5960.
*
* Due to the changes in WICKET-5309, a page is re-rendered when any of the URL segments is
* modified during the request. The re-render causes the {@code <head>} section to be empty
* because it was already rendered in the first try.
*/
@Test
public void wicket5960() {
// mount the page so we have URL segments
tester.getApplication().mount(new MountedMapper("/rerender/${value}", RerenderPage.class));
// start the page with a value of 1
PageParameters pars = new PageParameters();
pars.add("value", 1);
// render the page
RerenderPage page = tester.startPage(RerenderPage.class, pars);
tester.assertRenderedPage(RerenderPage.class);
tester.assertContains("<!-- I should be present 1 -->");
// add a supplier to modify the URL during render
page.setNewValueHandler(new Supplier<Integer>() {
private static final long serialVersionUID = 1L;
@Override
public Integer get() {
return 2;
}
});
// rerender the page
tester.startPage(page);
tester.assertRenderedPage(RerenderPage.class);
// due to the mentioned issue, no headers are rendered at all.
tester.assertContains("<!-- I should be present 2 -->");
}
use of org.apache.wicket.core.request.mapper.MountedMapper in project wicket by apache.
the class Application method init.
/**
* @see org.apache.wicket.examples.WicketExampleApplication#init()
*/
@Override
protected void init() {
super.init();
getRootRequestMapperAsCompound().add(new MountedMapper("/hello", HelloWorld.class));
}
use of org.apache.wicket.core.request.mapper.MountedMapper in project midpoint by Evolveum.
the class MidPointApplication method init.
@Override
public void init() {
super.init();
getCspSettings().blocking().disabled();
getJavaScriptLibrarySettings().setJQueryReference(new PackageResourceReference(MidPointApplication.class, // todo no jquery.js is found
"../../../../../webjars/AdminLTE/2.4.18/bower_components/jquery/dist/jquery.min.js"));
getComponentInstantiationListeners().add(new SpringComponentInjector(this, applicationContext, true));
systemConfigurationChangeDispatcher.registerListener(new DeploymentInformationChangeListener(this));
SystemConfigurationType config = getSystemConfigurationIfAvailable();
if (config != null) {
deploymentInfo = config.getDeploymentInformation();
}
ResourceSettings resourceSettings = getResourceSettings();
resourceSettings.setParentFolderPlaceholder("$-$");
resourceSettings.setHeaderItemComparator(new PriorityFirstComparator(true));
SecurePackageResourceGuard guard = (SecurePackageResourceGuard) resourceSettings.getPackageResourceGuard();
guard.addPattern("+*.woff2");
List<IStringResourceLoader> resourceLoaders = resourceSettings.getStringResourceLoaders();
resourceLoaders.add(0, new MidPointStringResourceLoader(localizationService));
IResourceStreamLocator locator = new CachingResourceStreamLocator(new MidPointResourceStreamLocator(resourceSettings.getResourceFinders()));
resourceSettings.setResourceStreamLocator(locator);
resourceSettings.setThrowExceptionOnMissingResource(false);
getMarkupSettings().setStripWicketTags(true);
getMarkupSettings().setStripComments(true);
if (RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) {
getDebugSettings().setAjaxDebugModeEnabled(true);
getDebugSettings().setDevelopmentUtilitiesEnabled(true);
initializeDevelopmentSerializers();
mount(new MountedMapper("/inspector", InspectorPage.class, new PageParametersEncoder()));
mount(new MountedMapper("/liveSession", LiveSessionsPage.class, new PageParametersEncoder()));
mount(new MountedMapper("/pageStore", PageStorePage.class, new PageParametersEncoder()));
}
// pretty url for resources (e.g. images)
mountFiles(ImgResources.BASE_PATH, ImgResources.class);
// exception handling an error pages
ApplicationSettings appSettings = getApplicationSettings();
appSettings.setAccessDeniedPage(PageError401.class);
appSettings.setInternalErrorPage(PageError.class);
appSettings.setPageExpiredErrorPage(PageError.class);
mount(new MountedMapper(MOUNT_INTERNAL_SERVER_ERROR, PageError.class, new PageParametersEncoder()));
mount(new MountedMapper(MOUNT_UNAUTHORIZED_ERROR, PageError401.class, new PageParametersEncoder()));
mount(new MountedMapper(MOUNT_FORBIDEN_ERROR, PageError403.class, new PageParametersEncoder()));
mount(new MountedMapper(MOUNT_NOT_FOUND_ERROR, PageError404.class, new PageParametersEncoder()));
mount(new MountedMapper(MOUNT_GONE_ERROR, PageError410.class, new PageParametersEncoder()));
getRequestCycleListeners().add(new LoggingRequestCycleListener(this));
getAjaxRequestTargetListeners().add(new AjaxRequestTarget.IListener() {
@Override
public void updateAjaxAttributes(AbstractDefaultAjaxBehavior behavior, AjaxRequestAttributes attributes) {
// check whether behavior will use POST method, if not then don't put CSRF token there
if (!isPostMethodTypeBehavior(behavior, attributes)) {
return;
}
CsrfToken csrfToken = SecurityUtils.getCsrfToken();
if (csrfToken == null) {
return;
}
String parameterName = csrfToken.getParameterName();
String value = csrfToken.getToken();
attributes.getExtraParameters().put(parameterName, value);
}
});
getSessionListeners().add((ISessionListener) asyncWebProcessManager);
// descriptor loader, used for customization
new PageMounter().loadData(this);
descriptorLoader.loadData();
if (applicationContext != null) {
Map<String, MidPointApplicationConfiguration> map = applicationContext.getBeansOfType(MidPointApplicationConfiguration.class);
if (map != null) {
map.forEach((key, value) -> value.init(this));
}
}
// for schrodinger selenide library
initializeSchrodinger();
ServletContext servletContext = getServletContext();
if (servletContext != null) {
taskManager.setWebContextPath(servletContext.getContextPath());
}
}
Aggregations