Package org.springframework.binding.validation.support

Examples of org.springframework.binding.validation.support.DefaultValidationResultsModel


     * When the results reporter is setup on the master form, we need to capture it and
     * forward it on to the detail form as well.
     */
    public ValidationResultsReporter newSingleLineResultsReporter(Messagable messageReceiver) {
        // create a resultsModel container which receives events from detail and master
        ValidationResultsModel validationResultsModel = new DefaultValidationResultsModel();
        validationResultsModel.add(getFormModel().getValidationResults());
        validationResultsModel.add(getDetailFormModel().getValidationResults());
        ValidationResultsReporter reporter = new SimpleValidationResultsReporter(validationResultsModel, messageReceiver);
        return reporter;
    }
View Full Code Here


    private TestValidationListener field1Listener;

    private TestValidationListener nullListener;

    public void setUp() {
        vrm = new DefaultValidationResultsModel();
        errorsListener = new TestPropertyChangeListener(ValidationResultsModel.HAS_ERRORS_PROPERTY);
        vrm.addPropertyChangeListener(ValidationResultsModel.HAS_ERRORS_PROPERTY, errorsListener);
        warnListener = new TestPropertyChangeListener(ValidationResultsModel.HAS_WARNINGS_PROPERTY);
        vrm.addPropertyChangeListener(ValidationResultsModel.HAS_WARNINGS_PROPERTY, warnListener);
        infoListener = new TestPropertyChangeListener(ValidationResultsModel.HAS_INFO_PROPERTY);
View Full Code Here

    public void testEventsHaveCorectSource() {
        vrm.updateValidationResults(getResults("field1", Severity.ERROR));
        assertEquals(vrm, errorsListener.lastEvent().getSource());
        assertEquals(vrm, listener.lastResults());
       
        ValidationResultsModel delegateFor = new DefaultValidationResultsModel();
        vrm = new DefaultValidationResultsModel(delegateFor);
        vrm.addValidationListener(listener);
        vrm.addPropertyChangeListener(ValidationResultsModel.HAS_ERRORS_PROPERTY, errorsListener);       
        vrm.updateValidationResults(getResults("field1", Severity.ERROR));
        assertEquals(delegateFor, errorsListener.lastEvent().getSource());
        assertEquals(delegateFor, listener.lastResults());
View Full Code Here

   
    /**
     * Simply check if {@link DefaultValidationResultsModel} counts its messages correctly.
     */
    public void testMessageCount() {
      DefaultValidationResultsModel resultsModel = new DefaultValidationResultsModel();
      resultsModel.addMessage(new DefaultValidationMessage("property1", Severity.ERROR, "message1"));
      resultsModel.addMessage(new DefaultValidationMessage("property1", Severity.INFO, "message2"));
      resultsModel.addMessage(new DefaultValidationMessage("property2", Severity.ERROR, "message3"));
      assertEquals("Number of messages should be 3", 3, resultsModel.getMessageCount());
      assertEquals("Number of messages registered for property1 should be 2", 2, resultsModel.getMessageCount("property1"));
      assertEquals("Number of messages flagged as INFO should be 1", 1, resultsModel.getMessageCount(Severity.INFO));
    }
View Full Code Here

    /**
     * Check if adding a child triggers the parent to fire appropriate events.
     */
    public void testAddChildEvents() {
      DefaultValidationResultsModel childModel = new DefaultValidationResultsModel();
     
      childModel.addMessage(new DefaultValidationMessage("childProperty1", Severity.ERROR, "childErrorMessage1"));
      childModel.addMessage(new DefaultValidationMessage("childProperty1", Severity.WARNING, "childWarningMessage1"));
      childModel.addMessage(new DefaultValidationMessage("childProperty1", Severity.INFO, "childInfoMessage1"));
      vrm.add(childModel);
      assertEquals("ParentModel adds child with Error.", 1, listener.eventCount());
      assertEquals("ChildModel has ErrorMessage.", 1, errorsListener.eventCount());
      assertEquals("ChildModel has WarningMessage.", 1, warnListener.eventCount());
      assertEquals("ChildModel has InfoMessage.", 1, infoListener.eventCount());
View Full Code Here

     
    /**
     * Check if adding a child triggers the parent to fire appropriate events.
     */
    public void testChildEvents() {
      DefaultValidationResultsModel childModel = new DefaultValidationResultsModel();
     
      vrm.add(childModel);
      childModel.addMessage(new DefaultValidationMessage("childProperty1", Severity.ERROR, "childErrorMessage1"));
      childModel.addMessage(new DefaultValidationMessage("childProperty1", Severity.WARNING, "childWarningMessage1"));
      childModel.addMessage(new DefaultValidationMessage("childProperty1", Severity.INFO, "childInfoMessage1"));
      assertEquals("Child added errorMessage, warningMessage and InfoMessage.", 3, listener.eventCount());
      assertEquals("ChildModel added ErrorMessage.", 1, errorsListener.eventCount());
      assertEquals("ChildModel added WarningMessage.", 1, warnListener.eventCount());
      assertEquals("ChildModel added InfoMessage.", 1, infoListener.eventCount());
      assertEquals("ChildModel added ErrorMessage.", Boolean.TRUE, errorsListener.lastEvent().getNewValue());
View Full Code Here

   
    /**
     * Check if adding a child triggers the parent to fire appropriate events.
     */
    public void testRemoveChildEvents() {
      DefaultValidationResultsModel childModel = new DefaultValidationResultsModel();
     
      childModel.addMessage(new DefaultValidationMessage("childProperty1", Severity.ERROR, "childErrorMessage1"));
      childModel.addMessage(new DefaultValidationMessage("childProperty1", Severity.WARNING, "childWarningMessage1"));
      childModel.addMessage(new DefaultValidationMessage("childProperty1", Severity.INFO, "childInfoMessage1"));
      vrm.add(childModel);
      vrm.remove(childModel);
      assertEquals("Child removed, revalidate.", 2, listener.eventCount());     
      assertEquals("Child removed, revalidate ErrorMessages.", 2, errorsListener.eventCount());
      assertEquals("Child removed, revalidate WarningMessages.", 2, warnListener.eventCount());
View Full Code Here

TOP

Related Classes of org.springframework.binding.validation.support.DefaultValidationResultsModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.