/**
 * 
 */
package org.richfaces.taglib;

import javax.el.ValueExpression;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.servlet.jsp.JspException;

import org.richfaces.validator.FacesBeanValidator;

public class BeanValidatorTag extends javax.faces.webapp.ValidatorELTag {


	/**
	 * 
	 */
	private static final long serialVersionUID = -5230299574915210593L;
	// Fields
		 	  			  		  	  
		/*
		 * summary
		 * Summary message for a validation errors.
		 */
		private ValueExpression _summary;
		/**
		 * Summary message for a validation errors.
		 * Setter for summary
		 * @param summary - new value
		 */
		 public void setSummary( ValueExpression  __summary ){
			this._summary = __summary;
	     }
	  
	 	 	

		
  protected Validator createValidator() throws JspException
  {
    FacesBeanValidator validator = (FacesBeanValidator) FacesContext.getCurrentInstance().getApplication().createValidator("org.richfaces.BeanValidator");
    _setProperties(validator);
    return validator;
  }

  // Support method to wire in properties
  private void _setProperties(FacesBeanValidator validator) throws JspException 
  {
    if (_summary != null) 
    {
      if (_summary instanceof ValueExpression) 
      {
        validator.setSummary(_summary);
      }
    }
  }
}
