// WARNING: This file was automatically generated. Do not edit it directly, | |
// or you will lose your changes. | |
/* | |
* Licensed to the Apache Software Foundation (ASF) under one | |
* or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information | |
* regarding copyright ownership. The ASF licenses this file | |
* to you under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, | |
* software distributed under the License is distributed on an | |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
* KIND, either express or implied. See the License for the | |
* specific language governing permissions and limitations | |
* under the License. | |
*/ | |
package $utils.getPackageFromFullClass($validator.tagClass); | |
import javax.faces.context.FacesContext; | |
import javax.el.ValueExpression; | |
import javax.faces.validator.Validator; | |
import javax.faces.application.Application; | |
import javax.servlet.jsp.JspException; | |
$utils.importTagClasses($validator) | |
public class $utils.getClassFromFullClass($validator.tagClass) | |
#if (${validator.tagSuperclass}) | |
extends ${validator.tagSuperclass} | |
#else | |
extends org.apache.myfaces.commons.validator.ValidatorBaseTag | |
#end | |
{ | |
#if ($validator.serialuidtag) | |
private static final long serialVersionUID = ${validator.serialuidtag}; | |
#end | |
public $utils.getClassFromFullClass($validator.tagClass)() | |
{ | |
} | |
#set ($propertyList = ${validator.propertyTagList}) | |
#foreach( $property in $propertyList ) | |
#set ($field = $property.fieldName) | |
#set ($type = $utils.getJspPropertyType12($property)) | |
private $type $field; | |
#set ($var = $utils.getVariableFromName($property.name)) | |
public void $utils.getPrefixedPropertyName("set", $property.jspName)($type $var) | |
{ | |
$field = $var; | |
} | |
#end | |
protected Validator createValidator() throws JspException { | |
String validatorId = "$validator.validatorId"; | |
Application appl = FacesContext.getCurrentInstance().getApplication(); | |
Validator validator = (Validator)appl.createValidator(validatorId); | |
_setProperties(validator); | |
return validator; | |
} | |
protected void _setProperties(Validator val) throws JspException { | |
super._setProperties(val); | |
FacesContext facesContext = FacesContext.getCurrentInstance(); | |
$validator.className validator = ($validator.className) val; | |
#foreach( $property in $propertyList ) | |
#set ($field = $property.fieldName) | |
#set ($type = $utils.getJspPropertyType12($property)) | |
#set ($className = $utils.getPrimitiveType($property.className)) | |
if ($field != null) | |
{ | |
#if ($property.isLiteralOnly()) | |
#if ($utils.isPrimitiveClass($property.className)) | |
validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field).${property.className}Value()); | |
#elseif ($utils.isPrimitiveClass($className)) | |
validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field)); | |
#else | |
validator.${utils.getPrefixedPropertyName("set",$property.name)}($field); | |
#end | |
#else | |
if (!${field}.isLiteralText()) | |
{ | |
validator.setValueExpression("$property.name", $field); | |
} | |
else | |
{ | |
#if ($utils.isPrimitiveClass($property.className)) | |
Object ${field}Value = ${field}.getValue(facesContext.getELContext()); | |
if (${field}Value != null){ | |
if (${field}Value instanceof ${utils.getBoxedClass($className)}){ | |
validator.${utils.getPrefixedPropertyName("set",$property.name)}( | |
((${utils.getBoxedClass($className)})${field}Value).${property.className}Value()); | |
} | |
else | |
{ | |
validator.${utils.getPrefixedPropertyName("set",$property.name)}( | |
${utils.getBoxedClass($className)}.valueOf(${field}Value.toString()).${property.className}Value()); | |
} | |
} | |
#elseif ($utils.isPrimitiveClass($className)) | |
Object ${field}Value = ${field}.getValue(facesContext.getELContext()); | |
if (${field}Value != null){ | |
if (${field}Value instanceof ${utils.getBoxedClass($className)}){ | |
validator.${utils.getPrefixedPropertyName("set",$property.name)}( | |
((${utils.getBoxedClass($className)})${field}Value)); | |
} | |
else | |
{ | |
validator.${utils.getPrefixedPropertyName("set",$property.name)}( | |
${utils.getBoxedClass($className)}.valueOf(${field}Value.toString())); | |
} | |
} | |
#elseif ($utils.getClassFromFullClass($property.className) == "String") | |
Object ${field}Value = ${field}.getValue(facesContext.getELContext()); | |
if (${field}Value != null) | |
{ | |
validator.${utils.getPrefixedPropertyName("set",$property.name)}( | |
($property.className) ${field}Value.toString()); | |
} | |
#elseif ($property.className == "java.lang.String[]") | |
try | |
{ | |
String[] value = org.apache.myfaces.commons.util.TagUtils.getStringArray(${field}.getValue(facesContext.getELContext())); | |
validator.${utils.getPrefixedPropertyName("set",$property.name)}(value); | |
} | |
catch (java.text.ParseException pe) | |
{ | |
throw new JspException( | |
pe.getMessage() + ": " + "Position " + pe.getErrorOffset()); | |
} | |
#else | |
validator.${utils.getPrefixedPropertyName("set",$property.name)}(($property.className) ${field}.getValue(facesContext.getELContext())); | |
#end | |
} | |
#end | |
} | |
#end | |
} | |
public void release() | |
{ | |
super.release(); | |
#foreach( $property in $propertyList ) | |
#set ($field = $property.fieldName) | |
#if($utils.getJspPropertyType12($property) == "boolean") | |
#set ($empty = "false") | |
#else | |
#set ($empty = "null") | |
#end | |
$field = $empty; | |
#end | |
} | |
} |