Search in sources :

Example 1 with ValidationTrackerImpl

use of org.apache.tapestry5.ValidationTrackerImpl in project tapestry-5 by apache.

the class AjaxFormUpdateControllerImpl method setupBeforePartialZoneRender.

public void setupBeforePartialZoneRender(MarkupWriter writer) {
    if (formComponentId == null)
        return;
    hiddenFieldPositioner = new HiddenFieldPositioner(writer, rules);
    actionSink = new ComponentActionSink(logger, clientDataEncoder);
    formSupport = createInternalFormSupport(formClientId, formComponentId, actionSink);
    environment.push(FormSupport.class, formSupport);
    environment.push(ValidationTracker.class, new ValidationTrackerImpl());
    heartbeat.begin();
}
Also used : ComponentActionSink(org.apache.tapestry5.corelib.internal.ComponentActionSink) HiddenFieldPositioner(org.apache.tapestry5.corelib.internal.HiddenFieldPositioner) ValidationTrackerImpl(org.apache.tapestry5.ValidationTrackerImpl)

Example 2 with ValidationTrackerImpl

use of org.apache.tapestry5.ValidationTrackerImpl in project tapestry-5 by apache.

the class ValidationTrackerImplTest method record_error_for_field.

@Test
public void record_error_for_field() {
    Field field = newFieldWithControlName("field");
    replay();
    ValidationTracker tracker = new ValidationTrackerImpl();
    assertFalse(tracker.getHasErrors());
    assertFalse(tracker.inError(field));
    assertNull(tracker.getError(field));
    tracker.recordError(field, "one");
    assertTrue(tracker.getHasErrors());
    assertTrue(tracker.inError(field));
    assertEquals(tracker.getError(field), "one");
    tracker.recordError(field, "two");
    assertEquals(tracker.getError(field), "two");
    verify();
}
Also used : Field(org.apache.tapestry5.Field) ValidationTracker(org.apache.tapestry5.ValidationTracker) ValidationTrackerImpl(org.apache.tapestry5.ValidationTrackerImpl) Test(org.testng.annotations.Test)

Example 3 with ValidationTrackerImpl

use of org.apache.tapestry5.ValidationTrackerImpl in project tapestry-5 by apache.

the class ValidationTrackerImplTest method clear_removes_all.

@Test
public void clear_removes_all() {
    Field fielda = newFieldWithControlName("fieldA");
    Field fieldb = newFieldWithControlName("fieldB");
    replay();
    ValidationTracker tracker = new ValidationTrackerImpl();
    tracker.recordError("one");
    tracker.recordInput(fieldb, "input b");
    tracker.recordError(fieldb, "fieldb: two");
    tracker.recordError("three");
    tracker.recordInput(fielda, "input a");
    tracker.recordError(fielda, "fielda: four");
    tracker.clear();
    assertFalse(tracker.getHasErrors());
    assertTrue(tracker.getErrors().isEmpty());
    assertNull(tracker.getInput(fielda));
    assertNull(tracker.getInput(fieldb));
    verify();
}
Also used : Field(org.apache.tapestry5.Field) ValidationTracker(org.apache.tapestry5.ValidationTracker) ValidationTrackerImpl(org.apache.tapestry5.ValidationTrackerImpl) Test(org.testng.annotations.Test)

Example 4 with ValidationTrackerImpl

use of org.apache.tapestry5.ValidationTrackerImpl in project tapestry-5 by apache.

the class ValidationTrackerImplTest method empty_tracker_has_no_errors.

@Test
public void empty_tracker_has_no_errors() {
    ValidationTracker tracker = new ValidationTrackerImpl();
    assertTrue(tracker.getErrors().isEmpty());
    assertFalse(tracker.getHasErrors());
}
Also used : ValidationTracker(org.apache.tapestry5.ValidationTracker) ValidationTrackerImpl(org.apache.tapestry5.ValidationTrackerImpl) Test(org.testng.annotations.Test)

Example 5 with ValidationTrackerImpl

use of org.apache.tapestry5.ValidationTrackerImpl in project tapestry-5 by apache.

the class ValidationTrackerImplTest method unsassoicated_errors_listed_first.

@Test
public void unsassoicated_errors_listed_first() {
    ValidationTracker tracker = new ValidationTrackerImpl();
    Field field = newFieldWithControlName("field");
    replay();
    tracker.recordError(field, "one");
    tracker.recordError("two");
    assertEquals(tracker.getErrors(), Arrays.asList("two", "one"));
    assertEquals(tracker.getUnassociatedErrors(), Arrays.asList("two"));
    verify();
}
Also used : Field(org.apache.tapestry5.Field) ValidationTracker(org.apache.tapestry5.ValidationTracker) ValidationTrackerImpl(org.apache.tapestry5.ValidationTrackerImpl) Test(org.testng.annotations.Test)

Aggregations

ValidationTrackerImpl (org.apache.tapestry5.ValidationTrackerImpl)9 ValidationTracker (org.apache.tapestry5.ValidationTracker)8 Test (org.testng.annotations.Test)8 Field (org.apache.tapestry5.Field)6 ComponentActionSink (org.apache.tapestry5.corelib.internal.ComponentActionSink)1 HiddenFieldPositioner (org.apache.tapestry5.corelib.internal.HiddenFieldPositioner)1