Search in sources :

Example 41 with StringValue

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")));
}
Also used : IRequestHandler(org.apache.wicket.request.IRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) BookmarkablePageRequestHandler(org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler) MockPageParametersAware(org.apache.wicket.MockPageParametersAware) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) IPageProvider(org.apache.wicket.core.request.handler.IPageProvider) StringValue(org.apache.wicket.util.string.StringValue) Url(org.apache.wicket.request.Url) IRequestParameters(org.apache.wicket.request.IRequestParameters) Test(org.junit.Test)

Example 42 with StringValue

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;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) StringValue(org.apache.wicket.util.string.StringValue)

Example 43 with StringValue

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;
        }
    };
}
Also used : AbstractResource(org.apache.wicket.request.resource.AbstractResource) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) StringValue(org.apache.wicket.util.string.StringValue)

Example 44 with StringValue

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));
}
Also used : IWritableRequestParameters(org.apache.wicket.request.IWritableRequestParameters) Model(org.apache.wicket.model.Model) IObjectClassAwareModel(org.apache.wicket.model.IObjectClassAwareModel) IModel(org.apache.wicket.model.IModel) IObjectClassAwareModel(org.apache.wicket.model.IObjectClassAwareModel) StringValue(org.apache.wicket.util.string.StringValue) Test(org.junit.Test)

Example 45 with StringValue

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());
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) StringValue(org.apache.wicket.util.string.StringValue)

Aggregations

StringValue (org.apache.wicket.util.string.StringValue)54 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)22 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 Test (org.junit.Test)7 Task (com.evolveum.midpoint.task.api.Task)6 Url (org.apache.wicket.request.Url)5 IOException (java.io.IOException)4 WebSession (org.apache.openmeetings.web.app.WebSession)4 RestartResponseException (org.apache.wicket.RestartResponseException)4 IRequestHandler (org.apache.wicket.request.IRequestHandler)3 AbstractResource (org.apache.wicket.request.resource.AbstractResource)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 ObjectViewDto (com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto)2 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)2 Vertex (com.tinkerpop.blueprints.Vertex)2 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)2 Template (eu.esdihumboldt.hale.server.model.Template)2 User (eu.esdihumboldt.hale.server.model.User)2 NonUniqueResultException (eu.esdihumboldt.util.blueprints.entities.NonUniqueResultException)2