|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.binding.validation.support.DefaultValidationResultsModel
public class DefaultValidationResultsModel
Default implementation of ValidationResultsModel
. Several events are
fired when validationResults are set and can be tracked by registering the
appropriate listener.
You can register listeners on:
addValidationListener(ValidationListener)
)addValidationListener(String, ValidationListener)
)A child-parent relation can be used to bundle events and results. A listener set on a parent will receive events originating from the child and when polling for messages, childMessages will be available as well. This makes it possible to efficiently couple formModels and their validation aspect and provides a means to bundle validation reporting. When eg using a {@link org.springframework.richclient.form.ValidationResultsReporter}, you have the opportunity to bundle results from various unrelated formModels to report to one end point.
Example:
DefaultFormModel formModelA = ... DefaultFormModel formModelChildOfA = ... formModelA.addChild(formModelChildOfA); DefaultFormModel formModelB = ... \\ At this stage, the ValidationResultsModel of formModelChildOfA will route results & \\ events to the ValidationResultsModel of formModelA DefaultValidationResultsModel container = new DefaultValidationResultsModel(); container.add(formModelA.getValidationResults()); container.add(formModelB.getValidationResults()); new SimpleValidationResultsReporter(container, messagable); \\ the reporter will now receive events & results of all formModels and can show messages of each of them
DefaultFormModel.addChild(org.springframework.binding.form.HierarchicalFormModel)
,
SimpleValidationResultsReporter
Field Summary |
---|
Fields inherited from interface org.springframework.binding.validation.ValidationResultsModel |
---|
HAS_ERRORS_PROPERTY, HAS_INFO_PROPERTY, HAS_WARNINGS_PROPERTY |
Constructor Summary | |
---|---|
DefaultValidationResultsModel()
Constructor without delegate. |
|
DefaultValidationResultsModel(ValidationResultsModel delegateFor)
Constructor with delegate. |
Method Summary | |
---|---|
void |
add(ValidationResultsModel validationResultsModel)
Add a validationResultsModel as a child to this one. |
void |
addMessage(ValidationMessage validationMessage)
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Register a listener to all properties of this publisher. |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Register a listener to a specific property. |
void |
addValidationListener(String propertyName,
ValidationListener listener)
Adds a listener that will be notified when there is any change to the set validation messages for the specified property. |
void |
addValidationListener(ValidationListener listener)
Adds a listener that will be notified when there is any change to the set of validation messages. |
void |
clearAllValidationResults()
|
protected void |
fireChangedEvents()
|
protected void |
firePropertyChange(String propertyName,
boolean oldValue,
boolean newValue)
|
protected void |
fireValidationResultsChanged()
|
protected void |
fireValidationResultsChanged(String propertyName)
|
boolean |
getHasErrors()
Returns true of there are any validation messages of
Severity.ERROR . |
boolean |
getHasInfo()
Returns true of there are any validation messages of
Severity.INFO . |
boolean |
getHasWarnings()
Returns true of there are any validation messages of
Severity.WARNING . |
int |
getMessageCount()
Returns the total number of validation messages. |
int |
getMessageCount(Severity severity)
Returns the total number of validation messages of the specified Severity. |
int |
getMessageCount(String propertyName)
Returns the total number of validation messages that apply to the specified property name. |
Set |
getMessages()
Returns a set holding all of the validation messages. |
Set |
getMessages(Severity severity)
Returns a set holding all of the validation messages of the specified Severity. |
Set |
getMessages(String propertyName)
Returns a set holding all of the validation messages that apply to the specified property name. |
protected EventListenerListHelper |
getPropertyChangeListeners(String propertyName)
|
protected EventListenerListHelper |
getValidationListeners(String propertyName)
|
void |
propertyChange(PropertyChangeEvent evt)
Forwarding of known property events coming from child models. |
void |
remove(ValidationResultsModel validationResultsModel)
Remove the given validationResultsModel from the list of children. |
void |
removeMessage(ValidationMessage validationMessage)
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove the listener from all properties of this publisher. |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Remove the listener from a specific property. |
void |
removeValidationListener(String propertyName,
ValidationListener listener)
Removes the provided validation listener. |
void |
removeValidationListener(ValidationListener listener)
Removes the provided validation listener. |
void |
replaceMessage(ValidationMessage messageToReplace,
ValidationMessage replacementMessage)
|
String |
toString()
|
void |
updateValidationResults(ValidationResults newValidationResults)
|
void |
validationResultsChanged(ValidationResults results)
DefaultValidationResultsModel registers itself as a
validationListener on it's children to forward the event. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DefaultValidationResultsModel()
public DefaultValidationResultsModel(ValidationResultsModel delegateFor)
delegateFor
- delegate object.Method Detail |
---|
public void updateValidationResults(ValidationResults newValidationResults)
public void addMessage(ValidationMessage validationMessage)
public void removeMessage(ValidationMessage validationMessage)
public void replaceMessage(ValidationMessage messageToReplace, ValidationMessage replacementMessage)
public void clearAllValidationResults()
public boolean getHasErrors()
ValidationResults
true
of there are any validation messages of
Severity.ERROR
.
getHasErrors
in interface ValidationResults
true
if this instance of one of its children has
errors contained in their results.public boolean getHasInfo()
ValidationResults
true
of there are any validation messages of
Severity.INFO
.
getHasInfo
in interface ValidationResults
true
if this instance of one of its children has
info contained in their results.public boolean getHasWarnings()
ValidationResults
true
of there are any validation messages of
Severity.WARNING
.
getHasWarnings
in interface ValidationResults
true
if this instance of one of its children has
warnings contained in their results.public int getMessageCount()
ValidationResults
getMessageCount
in interface ValidationResults
public int getMessageCount(Severity severity)
ValidationResults
getMessageCount
in interface ValidationResults
public int getMessageCount(String propertyName)
ValidationResults
getMessageCount
in interface ValidationResults
public Set getMessages()
ValidationResults
getMessages
in interface ValidationResults
public Set getMessages(Severity severity)
ValidationResults
getMessages
in interface ValidationResults
public Set getMessages(String propertyName)
ValidationResults
getMessages
in interface ValidationResults
public void addValidationListener(ValidationListener listener)
ValidationResultsModel
addValidationListener
in interface ValidationResultsModel
public void removeValidationListener(ValidationListener listener)
ValidationResultsModel
removeValidationListener
in interface ValidationResultsModel
public void addValidationListener(String propertyName, ValidationListener listener)
ValidationResultsModel
addValidationListener
in interface ValidationResultsModel
public void removeValidationListener(String propertyName, ValidationListener listener)
ValidationResultsModel
removeValidationListener
in interface ValidationResultsModel
public void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangePublisher
addPropertyChangeListener
in interface PropertyChangePublisher
listener
- the PropertyChangeListener
to register.public void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangePublisher
removePropertyChangeListener
in interface PropertyChangePublisher
listener
- the PropertyChangeListener
to remove.public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
PropertyChangePublisher
addPropertyChangeListener
in interface PropertyChangePublisher
propertyName
- the property to monitor.listener
- the PropertyChangeListener
to register.public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
PropertyChangePublisher
removePropertyChangeListener
in interface PropertyChangePublisher
propertyName
- the property that was being monitored.listener
- the PropertyChangeListener
to remove.protected void fireChangedEvents()
protected void fireValidationResultsChanged()
protected void fireValidationResultsChanged(String propertyName)
protected EventListenerListHelper getValidationListeners(String propertyName)
protected void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
protected EventListenerListHelper getPropertyChangeListeners(String propertyName)
public String toString()
toString
in class Object
public void add(ValidationResultsModel validationResultsModel)
add
in interface ValidationResultsModel
validationResultsModel
- public void remove(ValidationResultsModel validationResultsModel)
remove
in interface ValidationResultsModel
validationResultsModel
- public void validationResultsChanged(ValidationResults results)
DefaultValidationResultsModel
registers itself as a
validationListener on it's children to forward the event.
validationResultsChanged
in interface ValidationListener
results
- the set of valiation results, this set will incude results
for all properties even if the listener is only listening for changes to
a specific properties results.public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |