*/
public void testOldValuePresentInEventEvenIfNotParsed() throws Exception {
Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
Field field = (Field)form.getChild("stringfield");
Action button = (Action)form.getChild("action");
MockRequest request;
// Set a value on "stringfield", and submit using an action so that
// it stays in unparsed state
request = new MockRequest();
request.addParameter("stringfield", "foo");
request.addParameter("action", "pressed");
form.process(new FormContext(request));
// Now add an event listener that will check old an new value
field.addValueChangedListener(new ValueChangedListener (){
public void valueChanged(ValueChangedEvent event) {
assertEquals("Old value", "foo", (String)event.getOldValue());
assertEquals("New value", "bar", (String)event.getNewValue());
}
});
// Change value to "bar", still without explicit validation
// That will call the event listener
request = new MockRequest();
request.addParameter("stringfield", "bar");
request.addParameter("button", "pressed");
form.process(new FormContext(request));
}