Package org.springframework.binding.validation.support

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


import org.springframework.richclient.dialog.MessageDialog;

public class BasicMessageDialog extends MessageDialog {

  public BasicMessageDialog() {
    super("Title", new DefaultValidationMessage("Property", Severity.ERROR, "message"));
  }
View Full Code Here


        fm.setValidator(v);
        ValueModel vm = fm.getValueModel("simpleProperty");
        // starting at 2: constructing a formmodel + creating valueModel
        int expectedCount = 2;

        final DefaultValidationMessage message1 = new DefaultValidationMessage("simpleProperty", Severity.ERROR, "1");

        fm.raiseValidationMessage(message1);
        assertEquals(expectedCount++, v.count);
        assertEquals(1, r.getMessageCount());
        assertContainsMessage("1", r.getMessages());
View Full Code Here

        return res;
    }

    private void assertContainsMessage(String message, Set messages) {
        assertTrue("Set of messages does not contain expected message '" + message + "'", messages
                .contains(new DefaultValidationMessage("simpleProperty", Severity.ERROR, message)));
    }
View Full Code Here

  public void testInfoMessage() {
    singleMessage(Severity.INFO);
  }

  private void singleMessage(Severity severity) {
    ValidationMessage message = new DefaultValidationMessage("property", severity, "message");
    defaultValidationResultsModel.addMessage(message);
    assertEquals(message, messagable.getMessage());
  }
View Full Code Here

            setValidator(new TestValidator());
            setBindingErrorMessageProvider(new BindingErrorMessageProvider() {

                public ValidationMessage getErrorMessage(FormModel formModel, String propertyName,
                        Object valueBeingSet, Exception e) {
                    return new DefaultValidationMessage(propertyName, Severity.ERROR, "");
                }

            });
        }
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

     */
    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

    public ValidationMessage getErrorMessage(FormModel formModel, String propertyName, Object valueBeingSet, Exception e) {
        String messageCode = getMessageCodeForException(e);
        Object[] args = new Object[] {formModel.getFieldFace(propertyName).getDisplayName(),
                UserMetadata.isFieldProtected(formModel, propertyName) ? "***" : valueBeingSet};
        String message = getMessageSourceAccessor().getMessage(messageCode, args, messageCode);
        return new DefaultValidationMessage(propertyName, Severity.ERROR, message);
    }
View Full Code Here

TOP

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

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.