Search in sources :

Example 1 with IWritableRequestParameters

use of org.apache.wicket.request.IWritableRequestParameters 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)

Aggregations

IModel (org.apache.wicket.model.IModel)1 IObjectClassAwareModel (org.apache.wicket.model.IObjectClassAwareModel)1 Model (org.apache.wicket.model.Model)1 IWritableRequestParameters (org.apache.wicket.request.IWritableRequestParameters)1 StringValue (org.apache.wicket.util.string.StringValue)1 Test (org.junit.Test)1