use of org.apache.wicket.request.IRequestParameters in project wicket by apache.
the class ServletWebRequest method generatePostParameters.
protected Map<String, List<StringValue>> generatePostParameters() {
Map<String, List<StringValue>> postParameters = new HashMap<>();
IRequestParameters queryParams = getQueryParameters();
@SuppressWarnings("unchecked") Map<String, String[]> params = getContainerRequest().getParameterMap();
for (Map.Entry<String, String[]> param : params.entrySet()) {
final String name = param.getKey();
final String[] values = param.getValue();
if (name != null && values != null) {
// build a mutable list of query params that have the same name as the post param
List<StringValue> queryValues = queryParams.getParameterValues(name);
if (queryValues == null) {
queryValues = Collections.emptyList();
} else {
queryValues = new ArrayList<>(queryValues);
}
// the list that will contain accepted post param values
List<StringValue> postValues = new ArrayList<>();
for (String value : values) {
StringValue val = StringValue.valueOf(value);
if (queryValues.contains(val)) {
// if a query param with this value exists remove it and continue
queryValues.remove(val);
} else {
// there is no query param with this value, assume post
postValues.add(val);
}
}
if (!postValues.isEmpty()) {
postParameters.put(name, postValues);
}
}
}
return postParameters;
}
use of org.apache.wicket.request.IRequestParameters in project wicket by apache.
the class BehaviorUrlTest method testBehaviorUrlNotDoubleEscaped.
@Test
public void testBehaviorUrlNotDoubleEscaped() {
tester.startPage(EscapeTestPage.class);
String response = tester.getLastResponseAsString();
// System.err.println(response);
assertTrue(response.contains(EscapeTestPage.TEST_QUERY_STRING));
tester.executeAjaxEvent("form:textfield", "change");
EscapeTestPage testPage = (EscapeTestPage) tester.getLastRenderedPage();
IRequestParameters lastParameters = testPage.getLastQueryParameters();
assertEquals(StringValue.valueOf("value_1"), lastParameters.getParameterValue("query_p_1"));
}
use of org.apache.wicket.request.IRequestParameters in project wiquery by WiQuery.
the class WiQueryAbstractAjaxBehavior method respond.
@Override
protected void respond(AjaxRequestTarget target) {
IRequestParameters req = RequestCycle.get().getRequest().getRequestParameters();
String eventName = req.getParameterValue("eventName").toString();
IComplexOption callback = options.getComplexOption(eventName);
if (callback instanceof AbstractAjaxEventCallback) {
((AbstractAjaxEventCallback) callback).call(target, getComponent());
}
}
use of org.apache.wicket.request.IRequestParameters in project java-design-patterns by iluwatar.
the class SimpleApplication method newSession.
@Override
public Session newSession(final Request request, final Response response) {
if (!DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS) {
return super.newSession(request, response);
}
// else demo mode
final AuthenticatedWebSessionForIsis s = (AuthenticatedWebSessionForIsis) super.newSession(request, response);
IRequestParameters requestParameters = request.getRequestParameters();
final org.apache.wicket.util.string.StringValue user = requestParameters.getParameterValue("user");
final org.apache.wicket.util.string.StringValue password = requestParameters.getParameterValue("pass");
s.signIn(user.toString(), password.toString());
return s;
}
use of org.apache.wicket.request.IRequestParameters in project webanno by webanno.
the class AnnotationPage method createUrlFragmentBehavior.
private UrlParametersReceivingBehavior createUrlFragmentBehavior() {
return new UrlParametersReceivingBehavior() {
private static final long serialVersionUID = -3860933016636718816L;
@Override
protected void onParameterArrival(IRequestParameters aRequestParameters, AjaxRequestTarget aTarget) {
aTarget.addChildren(getPage(), IFeedback.class);
StringValue project = aRequestParameters.getParameterValue(PAGE_PARAM_PROJECT_ID);
StringValue document = aRequestParameters.getParameterValue(PAGE_PARAM_DOCUMENT_ID);
StringValue focus = aRequestParameters.getParameterValue(PAGE_PARAM_FOCUS);
handleParameters(aTarget, project, document, focus, false);
}
};
}
Aggregations