1. opensymphony
  2. osworkflow


osworkflow / docs / Validators.html

<html><head><title>OSWorkflow Validators</title></head><body>
<ul class="star">
<li>Up to <a href="Documentation.html">Documentation</a></li>
<li>Back to <a href="Utility_Functions.html">Utility Functions</a></li>
<li>Forward to <a href="Registers.html">Registers</a></li>
</ul><p class="paragraph"></p>Just like <a href="Functions.html">Functions</a>, OSWorkflow allows for validators in three different forms: <b class="bold">Java-based</b>, <b class="bold">BeanShell</b>, and <b class="bold">BSF</b>. Java-based validators must implement the <b class="bold">com.opensymphony.workflow.Validator</b> interface (or in the case of <b class="bold">remote-ejb</b>'s, the <b class="bold">com.opensymphony.workflow.ValidatorRemote</b> interface). With Java-based validators, throwing an InvalidInputException is all that is needed to mark an input as invalid and stop the workflow action from occuring.<p class="paragraph"></p>But in BeanShell and BSF, things are a little different, since exceptions thrown in the scripts can't propogate out to the Java runtime environment. To get around this, any value returned in a BeanShell or BSF script will be used as the error message(s). The logic is as follows:
<ul class="minus">
<li>If the value returned is an InvalidInputException object, that object is immediately thrown to the client</li>
<li>If the value returned is a Map, that Map is used for the error/errorMessage pairs in the InvalidInputException</li>
<li>If the value returned is a String, the even numbers are used as keys, and the odd numbers are used as values to construct a Map that can then be used in the above case.</li>
<li>Otherwise, the value is converted to a String and added as a generic error message.</li>
</ul><p class="paragraph"></p></body></html>