ru.sstu.web.jsf
Class JsfValidator<T>

java.lang.Object
  extended by ru.sstu.web.jsf.JsfValidator<T>
Type Parameters:
T - type of input value
Direct Known Subclasses:
NumberValidator, StringValidator

public class JsfValidator<T>
extends Object

JsfValidator class is most common JSF validator.

Since:
Web 1.0
Author:
Denis_Murashev

Constructor Summary
JsfValidator(javax.faces.context.FacesContext context, javax.faces.component.UIInput input, T value)
           
 
Method Summary
 boolean checkEquals(T object, String resourceId)
          Checks if field value equals to required value.
 boolean checkEquals(T object, String resourceId, Object... parameters)
          Checks if field value equals to required value.
 boolean checkExists(Object object, Object dbObject, String resourceId)
          Checks if object with given name is already exists.
 boolean checkExists(Object object, Object dbObject, String resourceId, Object... parameters)
          Checks if object with given name is already exists.
protected  javax.faces.context.FacesContext getContext()
           
protected  javax.faces.component.UIInput getInput()
           
protected  JsfMessages getMessages()
           
protected  T getValue()
           
 void sendError(String resourceId)
          Sets validation error.
 void sendError(String resourceId, Object... parameters)
          Sets validation error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsfValidator

public JsfValidator(javax.faces.context.FacesContext context,
                    javax.faces.component.UIInput input,
                    T value)
Parameters:
context - context
input - input
value - value
Method Detail

checkEquals

public boolean checkEquals(T object,
                           String resourceId)
Checks if field value equals to required value.

Parameters:
object - required value
resourceId - message id
Returns:
true if check is successful

checkEquals

public boolean checkEquals(T object,
                           String resourceId,
                           Object... parameters)
Checks if field value equals to required value.

Parameters:
object - required value
resourceId - message id
parameters - message parameters
Returns:
true if check is successful

checkExists

public boolean checkExists(Object object,
                           Object dbObject,
                           String resourceId)
Checks if object with given name is already exists.

Parameters:
object - changed object
dbObject - existing object
resourceId - message id
Returns:
true if check is successful

checkExists

public boolean checkExists(Object object,
                           Object dbObject,
                           String resourceId,
                           Object... parameters)
Checks if object with given name is already exists.

Parameters:
object - changed object
dbObject - existing object
resourceId - message id
parameters - message parameters
Returns:
true if check is successful

sendError

public void sendError(String resourceId)
Sets validation error.

Parameters:
resourceId - message resource id

sendError

public void sendError(String resourceId,
                      Object... parameters)
Sets validation error.

Parameters:
resourceId - message resource id
parameters - message parameters

getMessages

protected JsfMessages getMessages()
Returns:
message resources

getContext

protected javax.faces.context.FacesContext getContext()
Returns:
the context

getInput

protected javax.faces.component.UIInput getInput()
Returns:
the input

getValue

protected T getValue()
Returns:
the value


Copyright © 2011 TFI branch of Engels Instutute of Technology. All Rights Reserved.