001: /*
002: * Copyright (c) 2002-2006 by OpenSymphony
003: * All rights reserved.
004: */
005: package com.opensymphony.xwork;
006:
007: import java.util.Collection;
008: import java.util.Map;
009:
010: /**
011: * ValidationAware classes can accept Action (class level) or field level error messages. Action level messages are kept
012: * in a Collection. Field level error messages are kept in a Map from String field name to a List of field error msgs.
013: *
014: * @author plightbo
015: * @version $Revision: 861 $
016: */
017: public interface ValidationAware {
018:
019: /**
020: * Set the Collection of Action-level String error messages.
021: *
022: * @param errorMessages
023: */
024: void setActionErrors(Collection errorMessages);
025:
026: /**
027: * Get the Collection of Action-level error messages for this action. Error messages should not
028: * be added directly here, as implementations are free to return a new Collection or an
029: * Unmodifiable Collection.
030: *
031: * @return Collection of String error messages
032: */
033: Collection getActionErrors();
034:
035: /**
036: * Set the Collection of Action-level String messages (not errors).
037: */
038: void setActionMessages(Collection messages);
039:
040: /**
041: * Get the Collection of Action-level messages for this action. Messages should not be added
042: * directly here, as implementations are free to return a new Collection or an Unmodifiable
043: * Collection.
044: *
045: * @return Collection of String messages
046: */
047: Collection getActionMessages();
048:
049: /**
050: * Set the field error map of fieldname (String) to Collection of String error messages.
051: *
052: * @param errorMap
053: */
054: void setFieldErrors(Map errorMap);
055:
056: /**
057: * Get the field specific errors associated with this action. Error messages should not be added
058: * directly here, as implementations are free to return a new Collection or an Unmodifiable
059: * Collection.
060: *
061: * @return Map with errors mapped from fieldname (String) to Collection of String error messages
062: */
063: Map getFieldErrors();
064:
065: /**
066: * Add an Action-level error message to this Action.
067: *
068: * @param anErrorMessage
069: */
070: void addActionError(String anErrorMessage);
071:
072: /**
073: * Add an Action-level message to this Action.
074: */
075: void addActionMessage(String aMessage);
076:
077: /**
078: * Add an error message for a given field.
079: *
080: * @param fieldName name of field
081: * @param errorMessage the error message
082: */
083: void addFieldError(String fieldName, String errorMessage);
084:
085: /**
086: * Check whether there are any Action-level error messages.
087: *
088: * @return true if any Action-level error messages have been registered
089: */
090: boolean hasActionErrors();
091:
092: /**
093: * Checks whether there are any Action-level messages.
094: *
095: * @return true if any Action-level messages have been registered
096: */
097: boolean hasActionMessages();
098:
099: /**
100: * Note that this does not have the same meaning as in WW 1.x.
101: *
102: * @return (hasActionErrors() || hasFieldErrors())
103: */
104: boolean hasErrors();
105:
106: /**
107: * Check whether there are any field errors associated with this action.
108: *
109: * @return whether there are any field errors
110: */
111: boolean hasFieldErrors();
112: }
|