use of org.apache.wicket.util.string.StringValue in project wicket by apache.
the class WicketTesterTest method setMultiValueQueryParameter.
/**
* Asserting that multiple parameters added in request and PageParameters get processed
*/
@Test
public void setMultiValueQueryParameter() {
PageParameters parameters = new PageParameters();
parameters.add("q_1", "q_1_value_1");
parameters.add("q_1", "q_1_value_2");
IPageProvider testPageProvider = new PageProvider(MockPageParametersAware.class, parameters);
IRequestHandler pageRequestHandler = new BookmarkablePageRequestHandler(testPageProvider);
Url url = tester.getApplication().getRootRequestMapper().mapHandler(pageRequestHandler);
tester.getRequest().addParameter("q_2", "q_2_value_1");
tester.getRequest().addParameter("q_2", "q_2_value_2");
tester.getRequest().setUrl(url);
tester.processRequest();
MockPageParametersAware page = (MockPageParametersAware) tester.getLastRenderedPage();
IRequestParameters lastQueryParameter = page.getLastQueryParameters();
List<StringValue> q1ParameterValues = lastQueryParameter.getParameterValues("q_1");
assertTrue(q1ParameterValues.contains(StringValue.valueOf("q_1_value_1")));
assertTrue(q1ParameterValues.contains(StringValue.valueOf("q_1_value_2")));
List<StringValue> q2ParameterValues = lastQueryParameter.getParameterValues("q_2");
assertTrue(q2ParameterValues.contains(StringValue.valueOf("q_2_value_1")));
assertTrue(q2ParameterValues.contains(StringValue.valueOf("q_2_value_2")));
}
use of org.apache.wicket.util.string.StringValue in project wicket by apache.
the class MockHttpServletRequest method getParameterMap.
/**
* Get the map of all of the parameters.
*
* @return The parameters
*/
@Override
public Map<String, String[]> getParameterMap() {
Map<String, String[]> params = new HashMap<>(parameters);
for (String name : post.getParameterNames()) {
List<StringValue> values = post.getParameterValues(name);
for (StringValue value : values) {
String[] present = params.get(name);
if (present == null) {
params.put(name, new String[] { value.toString() });
} else {
String[] newval = new String[present.length + 1];
System.arraycopy(present, 0, newval, 0, present.length);
newval[newval.length - 1] = value.toString();
params.put(name, newval);
}
}
}
return params;
}
use of org.apache.wicket.util.string.StringValue in project wicket by apache.
the class MapperDemoResourceReference method getResource.
@Override
public IResource getResource() {
return new AbstractResource() {
private static final long serialVersionUID = 1L;
@Override
protected ResourceResponse newResourceResponse(Attributes attributes) {
ResourceResponse resourceResponse = new ResourceResponse();
PageParameters parameters = attributes.getParameters();
StringValue sheetParam = parameters.get("sheet");
StringValue formatParam = parameters.get("format");
final String responseText = String.format("You just printed sheet '%s' in format '%s'.\n\n\nPress browser's back button to go to the examples.", sheetParam, formatParam);
resourceResponse.setContentType("text/plain");
resourceResponse.setContentLength(responseText.length());
resourceResponse.setWriteCallback(new WriteCallback() {
@Override
public void writeData(Attributes attributes) {
attributes.getResponse().write(responseText);
}
});
return resourceResponse;
}
};
}
use of org.apache.wicket.util.string.StringValue in project wicket by apache.
the class AjaxEditableTest method testModelObjectClassInference.
/**
* <a href="https://issues.apache.org/jira/browse/WICKET-4259">WICKET-4259</a>
*/
@Test
public void testModelObjectClassInference() {
class IntegerModel extends Model<Integer> implements IObjectClassAwareModel<Integer> {
@Override
public Class<Integer> getObjectClass() {
return Integer.class;
}
}
IModel<Integer> integerModel = new IntegerModel();
AjaxEditableLabel<Integer> editableLabel = new AjaxEditableLabel<Integer>("test", integerModel);
editableLabel.getEditor().setVisible(true);
IWritableRequestParameters postParameters = (IWritableRequestParameters) tester.getRequestCycle().getRequest().getPostParameters();
postParameters.setParameterValues(editableLabel.getEditor().getInputName(), Arrays.asList(new StringValue[] { StringValue.valueOf("5") }));
editableLabel.getEditor().processInput();
assertThat(integerModel.getObject(), instanceOf(Integer.class));
}
use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.
the class ContainerableListPanel method getStorageKey.
protected String getStorageKey() {
if (isCollectionViewPanelForCompiledView()) {
StringValue collectionName = getCollectionNameParameterValue();
String collectionNameValue = collectionName != null ? collectionName.toString() : "";
return WebComponentUtil.getObjectListPageStorageKey(collectionNameValue);
} else if (isCollectionViewPanelForWidget()) {
String widgetName = getWidgetNameOfCollection();
return WebComponentUtil.getObjectListPageStorageKey(widgetName);
}
return WebComponentUtil.getObjectListPageStorageKey(getDefaultType().getSimpleName());
}
Aggregations