use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.
the class ResourceMapper method mapRequest.
@Override
public IRequestHandler mapRequest(final Request request) {
final Url url = new Url(request.getUrl());
// now extract the page parameters from the request url
PageParameters parameters = extractPageParameters(request, mountSegments.length, parametersEncoder);
if (parameters != null) {
parameters.setLocale(resolveLocale());
}
// remove caching information from current request
removeCachingDecoration(url, parameters);
// check if url matches mount path
if (urlStartsWith(url, mountSegments) == false) {
return null;
}
// check if there are placeholders in mount segments
for (int index = 0; index < mountSegments.length; ++index) {
String placeholder = getPlaceholder(mountSegments[index]);
if (placeholder != null) {
// extract the parameter from URL
if (parameters == null) {
parameters = newPageParameters();
}
parameters.add(placeholder, url.getSegments().get(index), INamedParameters.Type.PATH);
}
}
return new ResourceReferenceRequestHandler(resourceReference, parameters);
}
use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.
the class AbstractAjaxBehavior method getCallbackUrl.
/**
* Gets the url that references this handler.
*
* @return the url that references this handler
*/
public CharSequence getCallbackUrl() {
Component component = getComponent();
if (component == null) {
throw new IllegalArgumentException("Behavior must be bound to a component to create the URL");
}
PageParameters parameters = new PageParameters();
PageParameters pageParameters = component.getPage().getPageParameters();
List<INamedParameters.NamedPair> allNamedInPath = pageParameters.getAllNamedByType(INamedParameters.Type.PATH);
for (INamedParameters.NamedPair namedPair : allNamedInPath) {
parameters.add(namedPair.getKey(), namedPair.getValue(), INamedParameters.Type.PATH);
}
return getComponent().urlForListener(this, parameters);
}
use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.
the class BaseWicketTester method submitForm.
/**
* Submits the {@link Form} in the last rendered {@link Page}.
* <p>
* <strong>Note</strong>: Form request parameters have to be set explicitely.
*
* @param path
* path to component
*/
public void submitForm(String path) {
Form<?> form = (Form<?>) getComponentFromLastRenderedPage(path);
Url url = Url.parse(form.getRootForm().urlForListener(new PageParameters()).toString(), Charset.forName(request.getCharacterEncoding()));
// make url absolute
transform(url);
request.setUrl(url);
processRequest();
}
use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.
the class BaseWicketTester method urlFor.
/**
* @param link
* @return url for Link
*/
public String urlFor(Link<?> link) {
Args.notNull(link, "link");
Url url = Url.parse(link.urlForListener(new PageParameters()).toString());
return transform(url).toString();
}
use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.
the class BookmarkablePageLinkTest method bookmarkableRequestWithInterceptWithParams.
/**
* @throws Exception
*/
@Test
void bookmarkableRequestWithInterceptWithParams() throws Exception {
PageParameters pp = new PageParameters();
pp.set("test", "test");
tester.startPage(BookmarkableThrowsInterceptPage.class, pp);
assertEquals(tester.getLastRenderedPage().getClass(), BookmarkableSetSecurityPage.class);
tester.startPage(BookmarkableContinueToPage.class);
assertEquals(tester.getLastRenderedPage().getClass(), BookmarkableThrowsInterceptPage.class);
}
Aggregations