Search in sources :

Example 1 with MockRequestParameters

use of org.apache.wicket.mock.MockRequestParameters in project wicket by apache.

the class BaseWicketTester method serializeFormToRequest.

/**
 * Puts all not already scheduled (e.g. via {@link FormTester#setValue(String, String)}) form
 * component values in the post parameters for the next form submit
 *
 * @param form
 *            the {@link Form} which components should be submitted
 */
private void serializeFormToRequest(final Form<?> form) {
    final MockRequestParameters postParameters = request.getPostParameters();
    final Set<String> currentParameterNamesSet = postParameters.getParameterNames();
    form.visitFormComponents(new IVisitor<FormComponent<?>, Void>() {

        @Override
        public void component(final FormComponent<?> formComponent, final IVisit<Void> visit) {
            final String inputName = formComponent.getInputName();
            if (!currentParameterNamesSet.contains(inputName)) {
                String[] values = FormTester.getInputValue(formComponent);
                for (String value : values) {
                    postParameters.addParameterValue(inputName, value);
                }
            }
        }
    });
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) MockRequestParameters(org.apache.wicket.mock.MockRequestParameters)

Aggregations

FormComponent (org.apache.wicket.markup.html.form.FormComponent)1 MockRequestParameters (org.apache.wicket.mock.MockRequestParameters)1