use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.
the class QueryStringWithVersionResourceCachingStrategyTest method testUndecorateUrl.
@Test
void testUndecorateUrl() throws Exception {
PageParameters urlParameters = new PageParameters();
urlParameters.add(versionParameter, TEST_RESOURCE_VERSION, INamedParameters.Type.QUERY_STRING);
ResourceUrl resourceUrl = new ResourceUrl("some-resource.txt", urlParameters);
strategy.undecorateUrl(resourceUrl);
assertEquals("some-resource.txt", resourceUrl.getFileName());
assertNull(resourceUrl.getParameters().get(versionParameter).toString());
}
use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.
the class FormComponentUpdatingBehavior method renderHead.
@Override
public void renderHead(Component component, IHeaderResponse response) {
CharSequence url = component.urlForListener(this, new PageParameters());
String event = getEvent();
String condition = String.format("if (event.target.name !== '%s') return; ", formComponent.getInputName());
Form<?> form = component.findParent(Form.class);
if (form != null) {
response.render(OnEventHeaderItem.forComponent(component, event, condition + form.getJsForListenerUrl(url.toString())));
} else {
char separator = url.toString().indexOf('?') > -1 ? '&' : '?';
response.render(OnEventHeaderItem.forComponent(component, event, condition + String.format("window.location.href='%s%s%s=' + %s;", url, separator, formComponent.getInputName(), getJSValue())));
}
}
use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.
the class StatelessForm method process.
/**
* Remove the page parameters for all form component otherwise they get appended to action URL
*
* {@inheritDoc}
*/
@Override
public void process(IFormSubmitter submittingComponent) {
// get the parameters before processing the form because the
// application may remove this form from its parent in #onSubmit() (WICKET-5158)
final PageParameters parameters = getPage().getPageParameters();
super.process(submittingComponent);
if (parameters != null) {
visitFormComponents(new IVisitor<FormComponent<?>, Void>() {
@Override
public void component(final FormComponent<?> formComponent, final IVisit<Void> visit) {
parameters.remove(formComponent.getInputName());
}
});
if (submittingComponent instanceof AbstractSubmitLink) {
AbstractSubmitLink submitLink = (AbstractSubmitLink) submittingComponent;
parameters.remove(submitLink.getInputName());
}
// remove the special parameter for IRequestListener
List<INamedParameters.NamedPair> namedParameters = parameters.getAllNamed();
Iterator<INamedParameters.NamedPair> iterator = namedParameters.iterator();
while (iterator.hasNext()) {
INamedParameters.NamedPair namedParameter = iterator.next();
if (Strings.isEmpty(namedParameter.getValue())) {
parameters.remove(namedParameter.getKey());
break;
}
}
}
}
use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.
the class AjaxCallbackUrlTest method getCallbackUrl.
private String getCallbackUrl(final String pageMountPath) {
WebApplication application = tester.getApplication();
application.mountPage(pageMountPath, TestPage.class);
application.getPageSettings().setRecreateBookmarkablePagesAfterExpiry(false);
PageParameters pageParameters = new PageParameters();
pageParameters.set("b", "BBB", INamedParameters.Type.PATH);
pageParameters.set("c", "CCC", INamedParameters.Type.PATH);
TestPage page = tester.startPage(TestPage.class, pageParameters);
return page.getAjaxCallbackUrl();
}
use of org.apache.wicket.request.mapper.parameter.PageParameters in project wicket by apache.
the class BookmarkableFolderContent method newContentComponent.
@Override
public Component newContentComponent(String id, final AbstractTree<Foo> tree, IModel<Foo> model) {
return new Folder<Foo>(id, tree, model) {
private static final long serialVersionUID = 1L;
@Override
protected MarkupContainer newLinkComponent(String id, IModel<Foo> model) {
Foo foo = model.getObject();
if (tree.getProvider().hasChildren(foo)) {
return super.newLinkComponent(id, model);
} else {
PageParameters parameters = new PageParameters();
parameters.add("foo", foo.getId());
return new BookmarkablePageLink<>(id, tree.getPage().getClass(), parameters);
}
}
};
}
Aggregations