org.mentawai.filter
Class ValidatorFilter

java.lang.Object
  extended by org.mentawai.filter.ValidatorFilter
All Implemented Interfaces:
Filter

public class ValidatorFilter
extends Object
implements Filter

A filter to validate the values of an action input. This filter has the same behaviour of a ValidationFilter except that it will get the validation information from the action, if it implements the Validatable interface.

Author:
Sergio Oliveira

Constructor Summary
ValidatorFilter()
          Creates a Validator filter.
ValidatorFilter(String resultForError)
           
 
Method Summary
 void destroy()
          Gives a chance to the filter to deallocalte any resources before it is destroyed.
 String filter(InvocationChain chain)
          Executes the filter.
static String getDir()
           
 void setDir(String dir)
          Sets the directory where to look for error messages.
 void setResultForError(String resultForError)
          By default, the filter returns the BaseAction.ERROR when a validation failure happens.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidatorFilter

public ValidatorFilter()
Creates a Validator filter.


ValidatorFilter

public ValidatorFilter(String resultForError)
Method Detail

getDir

public static String getDir()

setResultForError

public void setResultForError(String resultForError)
By default, the filter returns the BaseAction.ERROR when a validation failure happens. You can change that by calling this method.

Parameters:
resultForError - The result to return in case of a validation failure.

setDir

public void setDir(String dir)
Sets the directory where to look for error messages. You should only call this method if you want to change the default directory, which is /validation. Note that calling this method will force the change of the message context of this filter to ClassMessageContext with the given directory.

Parameters:
dir - The directory where to look for error messages.

filter

public String filter(InvocationChain chain)
              throws Exception
Description copied from interface: Filter
Executes the filter.

Specified by:
filter in interface Filter
Parameters:
chain - The InvocationChain for the action this filter is being applied to.
Returns:
The result of the filter or the action the filter is being applied to.
Throws:
Exception

destroy

public void destroy()
Description copied from interface: Filter
Gives a chance to the filter to deallocalte any resources before it is destroyed. This is called when the web application is stopped, in other words, this has nothing to do with garbage collection.

Specified by:
destroy in interface Filter


Copyright © 2013. All Rights Reserved.