## Velocity template used to generate trinidad JSF1.2-compatible component classes | |
## from component meta-data. | |
## | |
## Note that there are two types of component generation: | |
## * "subclass mode" (use annotated class as a parent class) | |
## * "template mode" (use annotated class as a template) | |
## This template file is used for both. | |
## | |
## Variable $component refers to a ComponentMeta object to process | |
## Variable $utils refers to an instance of MyfacesUtils. | |
## | |
## When "template mode" is being used then variable $innersource | |
## holds a String containing all the non-abstract functions defined | |
## in the annotated class. | |
## | |
/* | |
* 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 ${component.packageName}; | |
import java.util.HashMap; | |
import java.util.Map; | |
import javax.el.ValueExpression; | |
import javax.faces.context.FacesContext; | |
$utils.importTagClasses($component) | |
import org.apache.myfaces.trinidad.bean.FacesBean; | |
import org.apache.myfaces.trinidad.bean.PropertyKey; | |
import org.apache.myfaces.trinidad.util.ComponentUtils; | |
#if ($component.isTemplate()) | |
#set ($generatedClassParent = $component.sourceClassParentClassName) | |
#else | |
#set ($generatedClassParent = $component.sourceClassName) | |
#end | |
// Generated from class ${component.sourceClassName}. | |
// | |
// WARNING: This file was automatically generated. Do not edit it directly, | |
// or you will lose your changes. | |
public class ${utils.getClassFromFullClass($component.className)} extends $generatedClassParent | |
#if ($component.implements) | |
implements $component.implements | |
#end | |
{ | |
#if ($component.serialuid) | |
private static final long serialVersionUID = ${component.serialuid}; | |
#end | |
static public final FacesBean.Type TYPE = new FacesBean.Type( | |
${generatedClassParent}.TYPE); | |
#set ($propertyList = ${component.propertyComponentList}) | |
#foreach( $property in $propertyList ) | |
#set ($field = $property.fieldName) | |
#set ($type = $utils.getClassFromFullClass($property.className)) | |
#set ($key = $utils.getConstantNameFromProperty($property.name , "_KEY")) | |
## | |
## CALCULATE DEFAULT VALUE | |
## | |
#if($utils.getDefaultValueField($property)) | |
#set ($defaultValue = $utils.getDefaultValueField($property)) | |
#if ($defaultValue == "true") | |
#set ($defaultValue = "Boolean.TRUE") | |
#end | |
#if ($defaultValue == "false") | |
#set ($defaultValue = "Boolean.FALSE") | |
#end | |
#if ($type == "char") | |
#set ($defaultValue = "'"+$defaultValue+"'") | |
#end | |
#else | |
#set ($defaultValue = false) | |
#end | |
## CALCULATE CAPABILITIES | |
#set ($caps = "") | |
#set ($capsCount = 0) | |
#if ($property.isMethodBinding() || $property.isLiteralOnly()) | |
#set ($capsCount = $capsCount + 1) | |
#end | |
#if ($property.isStateHolder()) | |
#set ($capsCount = $capsCount + 1) | |
#end | |
#if ($property.isTransient()) | |
#set ($capsCount = $capsCount + 1) | |
#end | |
#if ($property.isMethodBinding() || $property.isLiteralOnly()) | |
#set ($caps = $caps + "PropertyKey.CAP_NOT_BOUND") | |
#if ($capsCount > 1)#set($capsCount = $capsCount - 1)#set($caps=$caps+" | ")#end | |
#end | |
#if ($property.isStateHolder()) | |
#set ($caps = $caps + "PropertyKey.CAP_STATE_HOLDER") | |
#if ($capsCount > 1)#set($capsCount = $capsCount - 1)#set($caps=$caps+" | ")#end | |
#end | |
#if ($property.isTransient()) | |
#set ($caps = $caps + "PropertyKey.CAP_TRANSIENT") | |
#if ($capsCount > 1)#set($capsCount = $capsCount - 1)#set($caps=$caps+" | ")#end | |
#end | |
## This template does not handle PropertyKey.CAP_LIST | |
static public final PropertyKey $key = | |
TYPE.registerKey( | |
"$property.name",#if($utils.isPrimitiveClass($type))${utils.getBoxedClass($type)}.class#{else}${type}.class#end | |
#if($defaultValue),${defaultValue}#end | |
#if ( !$caps.equals("")),${caps}#end); | |
#end | |
static public final String COMPONENT_FAMILY = | |
"$component.family"; | |
static public final String COMPONENT_TYPE = | |
"$component.type"; | |
##if ($component.rendererType) | |
##if (!($component.rendererType == "")) | |
## static public final String DEFAULT_RENDERER_TYPE = | |
## "$component.rendererType"; | |
##end | |
##end | |
#if ($innersource) | |
//BEGIN CODE COPIED FROM $component.sourceClassName | |
$innersource | |
//END CODE COPIED FROM $component.sourceClassName | |
#end | |
public ${utils.getClassFromFullClass($component.className)}() | |
{ | |
#if ($component.rendererType) | |
#if ($component.rendererType == "") | |
super(null); | |
#else | |
super("$component.rendererType"); | |
#end | |
#else | |
super(null); | |
#end | |
} | |
#foreach( $property in $propertyList ) | |
#set ($field = $property.fieldName) | |
#set ($type = $utils.getClassFromFullClass($property.className)) | |
#set ($key = $utils.getConstantNameFromProperty($property.name , "_KEY")) | |
final public $type $utils.getMethodReaderFromProperty($property.name, $type)() | |
{ | |
#if ($utils.isPrimitiveClass($type)) | |
#if ($type == "char") | |
return ComponentUtils.resolveCharacter((Character) getProperty($key)); | |
#elseif ($type == "byte" || $type == "short") | |
## There is no ComponentUtils remethod, so we just cast it. | |
return $utils.castIfNecessary($type) getProperty($key); | |
#else | |
return ComponentUtils.resolve${utils.getBoxedClass($type)}(getProperty($key)); | |
#end | |
#elseif ($type == "String" || $type == "Locale" || $type == "TimeZone") | |
return ComponentUtils.resolve${utils.getBoxedClass($type)}(getProperty($key)); | |
#else | |
return $utils.castIfNecessary($type) getProperty($key); | |
#end | |
} | |
final public void $utils.getPrefixedPropertyName("set", $property.name)($type $utils.getVariableFromName($property.name)) | |
{ | |
#if ($utils.isPrimitiveClass($type)) | |
#if ($type == "boolean") | |
setProperty($key, $utils.getVariableFromName($property.name) ? Boolean.TRUE : Boolean.FALSE); | |
#else | |
setProperty($key, ${utils.getBoxedClass($type)}.valueOf( $utils.getVariableFromName($property.name) )); | |
#end | |
#else | |
setProperty($key, $utils.getVariableFromName($property.name)); | |
#end | |
} | |
#end | |
@Override | |
public String getFamily() | |
{ | |
return COMPONENT_FAMILY; | |
} | |
@Override | |
protected FacesBean.Type getBeanType() | |
{ | |
return TYPE; | |
} | |
public ${utils.getClassFromFullClass($component.className)}(String rendererType) | |
{ | |
super(rendererType); | |
} | |
static | |
{ | |
TYPE.lock(); | |
} | |
} |