You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/06/04 05:38:00 UTC
svn commit: r662966 [1/3] - in
/myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk:
core12/src/main/resources/META-INF/ sandbox/core12/src/
sandbox/core12/src/main/ sandbox/core12/src/main/conf/
sandbox/core12/src/main/conf/ME...
Author: lu4242
Date: Tue Jun 3 20:37:59 2008
New Revision: 662966
URL: http://svn.apache.org/viewvc?rev=662966&view=rev
Log:
component generation for tomahawk12
Added:
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/NOTICE.txt (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagClass12.vm
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagConverterClass12.vm
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagValidatorClass12.vm
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tomahawk12.vm
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/faces-config-base.xml (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/myfaces_sandbox-base.tld (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AbstractAjaxChildComboBox.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/comparetovalidator/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIEnsureConversation.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UISeparateConversationContext.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIStartConversation.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/focus2/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/focus2/AbstractHtmlFocus.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/focus2/HtmlFocusRenderer.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/focus2/TreeVisitor.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/requestParameterProvider/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/requestParameterProvider/RequestParameterResponseWrapper.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/suggestajax/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/suggestajax/AbstractSuggestAjax.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/suggestajax/AbstractSuggestAjaxTag.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/AbstractInputSuggestAjax.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/toggle/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/toggle/ToggleLinkRenderer.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeNotifierTag.java (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/resources/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/resources/META-INF/
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/resources/META-INF/LICENSE.txt (with props)
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/resources/META-INF/componentClass12.vm
myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/resources/META-INF/faces-config12.vm
Added: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/NOTICE.txt?rev=662966&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/NOTICE.txt (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/NOTICE.txt Tue Jun 3 20:37:59 2008
@@ -0,0 +1,32 @@
+Apache MyFaces
+Copyright 2004-2007 The Apache Software Foundation
+
+This product includes software developed by:
+The Apache Software Foundation (http://www.apache.org/).
+
+------------------------------------------------------------------------
+See the file LICENSE.txt
+See licenses for accompanying products in the "/licenses" subdirectory.
+------------------------------------------------------------------------
+
+This product includes software developed by Heng Yuan (jscookmenu)
+http://www.cs.ucla.edu/~heng/JSCookMenu
+
+This product includes software developed by Sam Stephenson (the ProtoType library)
+http://conio.net/
+
+This product includes software developed by Thomas Fuchs (the Ruby on Rails Ajax javascript extensions, script.aculo.us)
+http://script.aculo.us/
+
+This product includes software developed by the Kupu Project
+(http://kupu.oscom.org/).
+
+This product includes Sarissa ECMAScript written by Manos Batsis, released under
+the Kupu License with kind permission by the author (used by the Kupu HTML editor). See the Sarissa
+homepage at http://sarissa.sourceforge.net/ for more information.
+
+This product includes software developed by Guido Wesdorp (i18n.js, used by the KUPU html editor)
+(http://kupu.oscom.org/).
+
+This product includes software developed by Dojo Foundation (http://dojotoolkit.org/foundation/)
+http://www.dojotoolkit.org/
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagClass12.vm
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagClass12.vm?rev=662966&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagClass12.vm (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagClass12.vm Tue Jun 3 20:37:59 2008
@@ -0,0 +1,170 @@
+// 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 ${component.tagPackage};
+
+import javax.faces.component.UIComponent;
+import javax.el.ValueExpression;
+import javax.el.MethodExpression;
+import javax.faces.context.FacesContext;
+$utils.importTagClasses12($component)
+
+public class $utils.getClassFromFullClass($component.tagClass)
+#if (${component.tagSuperclass})
+ extends ${component.tagSuperclass}
+#else
+ extends javax.faces.webapp.UIComponentTag
+#end
+{
+ public $utils.getClassFromFullClass($component.tagClass)()
+ {
+ }
+
+ public String getComponentType()
+ {
+#if ($component.type)
+ return "$component.type";
+#else
+ return null;
+#end
+ }
+
+ public String getRendererType()
+ {
+#if ($component.rendererType)
+ return "$component.rendererType";
+#else
+ return null;
+#end
+ }
+
+#set ($propertyList = ${component.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 void setProperties(UIComponent component)
+ {
+ if (!(component instanceof $component.className))
+ {
+ throw new IllegalArgumentException("Component "+
+ component.getClass().getName() +" is no $component.className");
+ }
+
+ $component.className comp = ($component.className) component;
+
+ super.setProperties(component);
+
+ FacesContext context = getFacesContext();
+
+#foreach( $property in $propertyList )## 1
+#set ($field = $property.fieldName)
+#set ($type = $utils.getJspPropertyType12($property))
+#if ($utils.isConverter($property.className))## 2
+ if ($field != null)
+ {
+ if (!${field}.isLiteralText())
+ {
+ comp.setValueExpression("$property.name", $field);
+ }
+ else
+ {
+ String s = ${field}.getExpressionString();
+ if (s != null)
+ {
+ Converter converter = getFacesContext().getApplication().createConverter(s);
+ comp.setConverter(converter);
+ }
+ }
+ }
+#elseif ($property.isMethodBinding())## 2
+ if ($field != null)
+ {
+#if ($property.jspName == "actionListener")
+ comp.addActionListener(new MethodExpressionActionListener($field));
+#elseif ($property.jspName == "valueChangeListener")
+ comp.addValueChangeListener(new MethodExpressionValueChangeListener($field));
+#elseif ($property.jspName == "validator")
+ comp.addValidator(new MethodExpressionValidator($field));
+#elseif ($utils.isStringMethodBindingReturnType($property.methodBindingSignature))##3
+ MethodBinding mb;
+ if (isValueReference($field))
+ {
+ mb = context.getApplication().createMethodBinding(
+ $field, $utils.getSignatureParams($property.methodBindingSignature));
+ }
+ else
+ {
+ throw new IllegalStateException("Invalid expression " + $field);
+ }
+ comp.${utils.getPrefixedPropertyName("set",$property.name)}(mb);
+#else## 3
+ MethodBinding mb = context.getApplication().createMethodBinding(
+ $field, $utils.getSignatureParams($property.methodBindingSignature));
+ comp.${utils.getPrefixedPropertyName("set",$property.name)}(mb);
+#end## 3
+ }
+#elseif ($property.isMethodExpression())## 2
+ if ($field != null)
+ {
+#if ($property.jspName == "action")
+ comp.setActionExpression($field);
+#elseif ($property.jspName == "actionListener")
+ comp.addActionListener(new MethodExpressionActionListener($field));
+#else
+ comp.${utils.getPrefixedPropertyName("set",$property.name)}($field);
+#end
+ }
+#else## 2
+ if ($field != null)
+ {
+#if ($property.isLiteralOnly())## 3
+ comp.getAttributes().put("$property.name", $field);
+#else## 3
+ comp.setValueExpression("$property.name", $field);
+#end## 3
+ }
+#end## 2
+#end## 1
+ }
+
+ 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
+ }
+}
Added: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagConverterClass12.vm
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagConverterClass12.vm?rev=662966&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagConverterClass12.vm (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagConverterClass12.vm Tue Jun 3 20:37:59 2008
@@ -0,0 +1,167 @@
+// 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($converter.tagClass);
+
+import javax.faces.context.FacesContext;
+import javax.el.ELContext;
+import javax.faces.convert.Converter;
+import javax.el.ValueExpression;
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+$utils.importTagClasses($converter)
+
+public class $utils.getClassFromFullClass($converter.tagClass)
+#if (${converter.tagSuperclass})
+ extends ${converter.tagSuperclass}
+#else
+ extends org.apache.myfaces.converter.ConverterTag
+#end
+{
+#if ($converter.serialuidtag)
+ private static final long serialVersionUID = ${converter.serialuidtag};
+#end
+
+ public $utils.getClassFromFullClass($converter.tagClass)()
+ {
+ setConverterIdString("$converter.converterId");
+ }
+#set ($propertyList = ${converter.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
+
+ public void setPageContext(PageContext context) {
+ super.setPageContext(context);
+ setConverterIdString("$converter.converterId");
+ }
+
+ protected Converter createConverter() throws JspException {
+
+ ELContext elContext = FacesContext.getCurrentInstance().getELContext();
+ $converter.className converter = ($converter.className)super.createConverter();
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $utils.getJspPropertyType12($property))
+#set ($className = $utils.getPrimitiveType($property.className))
+ if ($field != null)
+ {
+ if (${field}.isLiteralText())
+ {
+#if ($utils.isPrimitiveClass($property.className))
+ String ${field}Value = ${field}.getExpressionString();
+ if (${field}Value != null)
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf(${field}Value).${property.className}Value());
+#elseif ($utils.isPrimitiveClass($className))
+ String ${field}Value = ${field}.getExpressionString();
+ if (${field}Value != null)
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf(${field}Value));
+ else
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(null);
+#elseif ($utils.getClassFromFullClass($property.className) == "String")
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(${field}.getExpressionString());
+#elseif ($utils.getClassFromFullClass($property.className) == "Object")
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(${field}.getExpressionString());
+#elseif ($utils.getClassFromFullClass($property.className) == "Locale")
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+ org.apache.myfaces.shared_tomahawk.util.LocaleUtils.converterTagLocaleFromString(${field}.getExpressionString()));
+#elseif ($utils.getClassFromFullClass($property.className) == "Class")
+ try
+ {
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+ org.apache.myfaces.shared_tomahawk.util.ClassUtils.classForName(${field}.getExpressionString()));
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new JspException(e);
+ }
+#elseif ($utils.getClassFromFullClass($property.className) == "TimeZone")
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+ java.util.TimeZone.getTimeZone(${field}.getExpressionString()));
+#else
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(($property.className) ${field}.getValue(elContext));
+#end
+ }
+ else
+ {
+#if ($utils.isPrimitiveClass($property.className))
+ Object ${field}Value = ${field}.getValue(elContext);
+ if (${field}Value != null)
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}( ((${utils.getBoxedClass($className)}) ${field}Value ).${property.className}Value());
+#elseif ($utils.isPrimitiveClass($className))
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}( (${utils.getBoxedClass($className)}) ${field}.getValue(elContext) );
+#elseif ($utils.getClassFromFullClass($property.className) == "Locale")
+ Object ${field}Value = ${field}.getValue(elContext);
+ if (${field}Value == null)
+ {
+ ${field}Value = FacesContext.getCurrentInstance().getViewRoot().getLocale();
+ }
+ if(!(${field}Value instanceof java.util.Locale))
+ {
+ ${field}Value = org.apache.myfaces.shared_tomahawk.util.LocaleUtils.converterTagLocaleFromString(${field}.getExpressionString());
+ }
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}((java.util.Locale)${field}Value);
+#elseif ($utils.getClassFromFullClass($property.className) == "TimeZone")
+ Object ${field}Value = ${field}.getValue(elContext);
+ if(${field}Value instanceof java.util.TimeZone)
+ {
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+ (java.util.TimeZone) ${field}Value);
+ }
+ else
+ {
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+ java.util.TimeZone.getTimeZone(${field}Value.toString()));
+ }
+#elseif ($utils.getClassFromFullClass($property.className) == "String")
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}( (String) ${field}.getValue(elContext));
+#else
+ converter.${utils.getPrefixedPropertyName("set",$property.name)}(($property.className) ${field}.getValue(elContext));
+#end
+ }
+ }
+#end
+ return converter;
+ }
+
+ 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
+ }
+}
Added: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagValidatorClass12.vm
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagValidatorClass12.vm?rev=662966&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagValidatorClass12.vm (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tagValidatorClass12.vm Tue Jun 3 20:37:59 2008
@@ -0,0 +1,137 @@
+// 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 javax.faces.webapp.ValidatorELTag;
+#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 (!${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());
+ }
+#else
+ validator.${utils.getPrefixedPropertyName("set",$property.name)}(($property.className) ${field}.getValue(facesContext.getELContext()));
+#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
+ }
+}
Added: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tomahawk12.vm
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tomahawk12.vm?rev=662966&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tomahawk12.vm (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/core12/src/main/resources/META-INF/tomahawk12.vm Tue Jun 3 20:37:59 2008
@@ -0,0 +1,218 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+-->
+<taglib xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
+ version="2.1">
+ <tlib-version>1.1.7</tlib-version>
+ <short-name>$shortname</short-name>
+ <uri>$uri</uri>
+ <display-name>$displayname</display-name>
+ <description>$description</description>
+
+$baseContent
+
+ <!-- Component Tags -->
+#set ($componentList = ${model.getComponents()})
+#foreach( $component in $componentList )
+#if ($modelIds.contains($component.modelId)
+ && ($component.name))
+#if ($utils.getTagPrefix($component.name) == $shortname)
+ <tag>
+ <name>$utils.getTagName($component.name)</name>
+ <tag-class>$component.tagClass</tag-class>
+#if ($component.bodyContent)
+ <body-content>$component.bodyContent</body-content>
+#else
+ <body-content>JSP</body-content>
+#end
+ <description><![CDATA[$component.longDescription]]></description>
+
+#set ($propertyList = ${component.propertyList})
+#foreach( $property in $propertyList )
+#if (!$property.isTagExcluded())
+ <attribute>
+ <name>$property.jspName</name>
+#if ($property.isRequired())
+ <required>$property.isRequired()</required>
+#end
+#if ($property.isMethodExpression() || $property.isMethodBinding())
+ <deferred-method>
+#if ($property.getMethodBindingSignature())
+#set ($sig = $property.getMethodBindingSignature())
+ <method-signature>$sig.returnType myMethod( $sig.parameterTypesAsString )</method-signature>
+#end
+ </deferred-method>
+#elseif ($property.isLiteralOnly())
+ <rtexprvalue>false</rtexprvalue>
+#else
+#set ($type = $utils.getClassFromFullClass($property.className))
+#if ($type == "String")
+ <deferred-value></deferred-value>
+#else
+ <deferred-value>
+ <type>$property.className</type>
+ </deferred-value>
+#end
+#end
+#if ($property.longDescription)
+ <description><![CDATA[$property.longDescription]]></description>
+#else
+ <description><![CDATA[]]></description>
+#end
+ </attribute>
+#end
+#end
+ </tag>
+#end
+#end
+#end
+ <!-- Converter tags -->
+#set ($componentList = ${model.getConverters()})
+#foreach( $component in $componentList )
+#if ($modelIds.contains($component.modelId)
+ && ($component.name))
+#if ($utils.getTagPrefix($component.name) == $shortname)
+ <tag>
+ <name>$utils.getTagName($component.name)</name>
+ <tag-class>$component.tagClass</tag-class>
+#if ($component.bodyContent)
+ <body-content>$component.bodyContent</body-content>
+#else
+ <body-content>empty</body-content>
+#end
+ <description><![CDATA[$component.longDescription]]></description>
+
+#set ($propertyList = ${component.propertyList})
+#foreach( $property in $propertyList )
+#if (!$property.isTagExcluded())
+ <attribute>
+ <name>$property.name</name>
+#if ($property.isRequired())
+ <required>$property.isRequired()</required>
+#end
+#if ($property.isLiteralOnly())
+ <rtexprvalue>false</rtexprvalue>
+#else
+#set ($type = $utils.getClassFromFullClass($property.className))
+#if ($type == "String")
+ <deferred-value></deferred-value>
+#else
+ <deferred-value>
+ <type>$property.className</type>
+ </deferred-value>
+#end
+#end
+#if ($property.longDescription)
+ <description><![CDATA[$property.longDescription]]></description>
+#else
+ <description><![CDATA[]]></description>
+#end
+ </attribute>
+#end
+#end
+ </tag>
+#end
+#end
+#end
+ <!-- Validator tags -->
+#set ($componentList = ${model.getValidators()})
+#foreach( $component in $componentList )
+#if ($modelIds.contains($component.modelId)
+ && ($component.name))
+#if ($utils.getTagPrefix($component.name) == $shortname)
+ <tag>
+ <name>$utils.getTagName($component.name)</name>
+ <tag-class>$component.tagClass</tag-class>
+#if ($component.bodyContent)
+ <body-content>$component.bodyContent</body-content>
+#else
+ <body-content>empty</body-content>
+#end
+ <description><![CDATA[$component.longDescription]]></description>
+
+#set ($propertyList = ${component.propertyList})
+#foreach( $property in $propertyList )
+#if (!$property.isTagExcluded())
+ <attribute>
+ <name>$property.name</name>
+#if ($property.isRequired())
+ <required>$property.isRequired()</required>
+#end
+#if ($property.isLiteralOnly())
+ <rtexprvalue>false</rtexprvalue>
+#else
+#set ($type = $utils.getClassFromFullClass($property.className))
+#if ($type == "String")
+ <deferred-value></deferred-value>
+#else
+ <deferred-value>
+ <type>$property.className</type>
+ </deferred-value>
+#end
+#end
+#if ($property.longDescription)
+ <description><![CDATA[$property.longDescription]]></description>
+#else
+ <description><![CDATA[]]></description>
+#end
+ </attribute>
+#end
+#end
+ </tag>
+#end
+#end
+#end
+ <!-- Single Tags -->
+#set ($tagList = $model.getTags())
+#foreach( $tag in $tagList )
+#if ($modelIds.contains($tag.modelId))
+ <tag>
+ <name>$utils.getTagName($tag.name)</name>
+ <tag-class>$tag.className</tag-class>
+ <body-content>$tag.bodyContent</body-content>
+ <description><![CDATA[$tag.longDescription]]></description>
+#set ($attributeList = ${tag.attributeList})
+#foreach( $attribute in $attributeList )
+ <attribute>
+ <name>$attribute.name</name>
+ <required>$attribute.isRequired()</required>
+#set ($type = $utils.getClassFromFullClass($attribute.className))
+#if ($type == "ValueExpression")
+ <deferred-value></deferred-value>
+#else
+ <rtexprvalue>$attribute.isRtexprvalue()</rtexprvalue>
+#if ($attribute.className)
+ <type>$attribute.className</type>
+#else
+ <type>java.lang.String</type>
+#end
+#end
+#if ($property.longDescription)
+ <description><![CDATA[$property.longDescription]]></description>
+#else
+ <description><![CDATA[]]></description>
+#end
+ </attribute>
+#end
+ </tag>
+#end
+#end
+</taglib>
\ No newline at end of file
Added: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/faces-config-base.xml
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/faces-config-base.xml?rev=662966&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/faces-config-base.xml (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/faces-config-base.xml Tue Jun 3 20:37:59 2008
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ * 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.
+-->
+
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+ version="1.2">
+
+ <lifecycle>
+ <phase-listener>org.apache.myfaces.custom.ajax.api.AjaxDecodePhaseListener</phase-listener>
+ <phase-listener>org.apache.myfaces.custom.valueChangeNotifier.ValueChangePhaseListener</phase-listener>
+ <phase-listener>org.apache.myfaces.custom.redirectTracker.RedirectTrackerPhaseListener</phase-listener>
+ <phase-listener>org.apache.myfaces.custom.ppr.PPRPhaseListener</phase-listener>
+ <phase-listener>org.apache.myfaces.custom.exporter.ExporterPhaseListener</phase-listener>
+ </lifecycle>
+
+ <application>
+ <variable-resolver>org.apache.myfaces.custom.redirectTracker.RedirectTrackerVariableResolver</variable-resolver>
+ <navigation-handler>org.apache.myfaces.custom.redirectTracker.RedirectTrackerNavigationHandler</navigation-handler>
+ <variable-resolver>org.apache.myfaces.custom.security.SecurityContextVariableResolver</variable-resolver>
+ <property-resolver>org.apache.myfaces.custom.security.SecurityContextPropertyResolver</property-resolver>
+ </application>
+
+ <factory>
+ <lifecycle-factory>org.apache.myfaces.custom.ppr.PPRLifecycleFactory</lifecycle-factory>
+ </factory>
+
+ <!-- sandbox managed beans -->
+ <managed-bean>
+ <managed-bean-name>ScopeContainer</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.custom.scope.ScopeHolder</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>CVCallsHolder</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.custom.clientvalidation.common.CVCallsHolder
+ </managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+ <!-- extended converters and validators -->
+ <converter>
+ <converter-id>javax.faces.Integer</converter-id>
+ <converter-class>org.apache.myfaces.convert.ex.IntegerConverter</converter-class>
+ </converter>
+ <converter>
+ <converter-for-class>java.lang.Integer</converter-for-class>
+ <converter-class>org.apache.myfaces.convert.ex.IntegerConverter</converter-class>
+ </converter>
+ <converter>
+ <converter-id>javax.faces.Double</converter-id>
+ <converter-class>org.apache.myfaces.convert.ex.DoubleConverter</converter-class>
+ </converter>
+ <converter>
+ <converter-for-class>java.lang.Double</converter-for-class>
+ <converter-class>org.apache.myfaces.convert.ex.DoubleConverter</converter-class>
+ </converter>
+ <converter>
+ <converter-id>javax.faces.Float</converter-id>
+ <converter-class>org.apache.myfaces.convert.ex.FloatConverter</converter-class>
+ </converter>
+ <converter>
+ <converter-for-class>java.lang.Float</converter-for-class>
+ <converter-class>org.apache.myfaces.convert.ex.FloatConverter</converter-class>
+ </converter>
+ <converter>
+ <converter-id>javax.faces.Long</converter-id>
+ <converter-class>org.apache.myfaces.convert.ex.LongConverter</converter-class>
+ </converter>
+ <converter>
+ <converter-for-class>java.lang.Long</converter-for-class>
+ <converter-class>org.apache.myfaces.convert.ex.LongConverter</converter-class>
+ </converter>
+ <converter>
+ <converter-id>javax.faces.Short</converter-id>
+ <converter-class>org.apache.myfaces.convert.ex.ShortConverter</converter-class>
+ </converter>
+ <converter>
+ <converter-for-class>java.lang.Short</converter-for-class>
+ <converter-class>org.apache.myfaces.convert.ex.ShortConverter</converter-class>
+ </converter>
+
+ <validator>
+ <validator-id>javax.faces.Length</validator-id>
+ <validator-class>org.apache.myfaces.validator.ex.LengthValidator</validator-class>
+ </validator>
+ <validator>
+ <validator-id>javax.faces.LongRange</validator-id>
+ <validator-class>org.apache.myfaces.validator.ex.LongRangeValidator</validator-class>
+ </validator>
+ <validator>
+ <validator-id>javax.faces.DoubleRange</validator-id>
+ <validator-class>org.apache.myfaces.validator.ex.DoubleRangeValidator</validator-class>
+ </validator>
+
+</faces-config>
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/faces-config-base.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/faces-config-base.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/myfaces_sandbox-base.tld
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/myfaces_sandbox-base.tld?rev=662966&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/myfaces_sandbox-base.tld (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/myfaces_sandbox-base.tld Tue Jun 3 20:37:59 2008
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * 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.
+-->
+<taglib xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
+ version="2.1">
+
+</taglib>
\ No newline at end of file
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/myfaces_sandbox-base.tld
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/conf/META-INF/myfaces_sandbox-base.tld
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AbstractAjaxChildComboBox.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AbstractAjaxChildComboBox.java?rev=662966&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AbstractAjaxChildComboBox.java (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AbstractAjaxChildComboBox.java Tue Jun 3 20:37:59 2008
@@ -0,0 +1,118 @@
+/*
+ * 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 org.apache.myfaces.custom.ajaxchildcombobox;
+
+import java.io.IOException;
+
+import javax.el.MethodExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.render.Renderer;
+
+import org.apache.myfaces.component.html.ext.HtmlSelectOneMenu;
+import org.apache.myfaces.custom.ajax.api.AjaxComponent;
+import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+
+/**
+ * Refreshes contents through an ajax call when the parent combo box's value is changed.
+ *
+ * This component is to be used in conjunction with a regular combo box or list box.
+ * When the selected value of the latter changes, it executes an ajax call to the
+ * specified method to refresh its contents based on the new selected value.
+ *
+ * @JSFComponent
+ * name = "s:ajaxChildComboBox"
+ * class = "org.apache.myfaces.custom.ajaxchildcombobox.AjaxChildComboBox"
+ * superClass = "org.apache.myfaces.custom.ajaxchildcombobox.AbstractAjaxChildComboBox"
+ * tagClass = "org.apache.myfaces.custom.ajaxchildcombobox.AjaxChildComboBoxTag"
+ *
+ * @author Sharath Reddy
+ */
+public abstract class AbstractAjaxChildComboBox extends HtmlSelectOneMenu implements AjaxComponent
+{
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.AjaxChildComboBox";
+ public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.AjaxChildComboBox";
+
+ public AbstractAjaxChildComboBox()
+ {
+ super();
+ setRendererType(AbstractAjaxChildComboBox.DEFAULT_RENDERER_TYPE);
+ }
+
+ public void encodeAjax(FacesContext context)
+ throws IOException
+ {
+
+ if (context == null) throw new NullPointerException("context");
+ if (!isRendered()) return;
+ Renderer renderer = getRenderer(context);
+ if (renderer != null && renderer instanceof AjaxRenderer)
+ {
+ ((AjaxRenderer) renderer).encodeAjax(context, this);
+ }
+ }
+
+ public void decodeAjax(FacesContext context)
+ {
+ //Do Nothing
+ }
+
+ /**
+ * Method to call via ajax to reload the combo box
+ *
+ * @JSFProperty
+ * methodSignature = "java.lang.String"
+ * returnSignature = "javax.faces.model.SelectItem []"
+ * stateHolder = "true"
+ */
+ public abstract MethodExpression getAjaxSelectItemsMethod();
+
+ //
+
+ /**
+ * id of the parent combo box
+ *
+ * This is not a 'Parent' in terms of the component heirarchy;
+ * This is the component whose 'onchange' event triggers a refresh.
+ *
+ * @JSFProperty
+ * literalOnly="true"
+ */
+ public abstract String getParentComboBox();
+
+
+ /**
+ * We cannot verify that the result of converting the newly submitted value
+ * is <i>equal</i> to the value property of one of the child SelectItem
+ * objects. This is because the contents of the child combo box could have
+ * been reloaded by a change in the parent combo box.
+ *
+ * @see javax.faces.component.UIInput#validateValue(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ protected void validateValue(FacesContext context, Object value)
+ {
+ return;
+ // selected value must match to one of the available options
+ /* if (!_SelectItemsUtil.matchValue(context, value, new _SelectItemsIterator(this), converter))
+ {
+ _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID,
+ new Object[] {getId()});
+ setValid(false);
+ }*/
+ }
+}
\ No newline at end of file
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AbstractAjaxChildComboBox.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/AbstractAjaxChildComboBox.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java?rev=662966&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java Tue Jun 3 20:37:59 2008
@@ -0,0 +1,174 @@
+/*
+ * 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 org.apache.myfaces.custom.ajaxchildcombobox;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.el.MethodExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UINamingContainer;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.model.SelectItem;
+import javax.servlet.ServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
+import org.apache.myfaces.custom.dojo.DojoConfig;
+import org.apache.myfaces.custom.dojo.DojoUtils;
+import org.apache.myfaces.renderkit.html.ext.HtmlMenuRenderer;
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+
+/**
+ * Renderer for component HtmlAjaxChildComboBox
+ *
+ * @JSFRenderer
+ * renderKitId = "HTML_BASIC"
+ * family = "javax.faces.SelectOne"
+ * type = "org.apache.myfaces.AjaxChildComboBox"
+ *
+ * @author Sharath Reddy
+ */
+public class HtmlAjaxChildComboBoxRenderer extends HtmlMenuRenderer implements AjaxRenderer
+{
+ private static final String BEGIN_OPTION = "<option>";
+ private static final String END_OPTION = "</option>";
+ private static final String BEGIN_OPTION_TEXT = "<optionText>";
+ private static final String END_OPTION_TEXT = "</optionText>";
+ private static final String BEGIN_OPTION_VALUE = "<optionValue>";
+ private static final String END_OPTION_VALUE = "</optionValue>";
+
+ public static final int DEFAULT_MAX_SUGGESTED_ITEMS = 200;
+
+ private static Log log = LogFactory.getLog(HtmlAjaxChildComboBoxRenderer.class);
+
+ // Adds the javascript files needed by Dojo and the custom javascript for
+ // this
+ // component
+ private void encodeJavascript(FacesContext context, UIComponent component)
+ throws IOException
+ {
+ String javascriptLocation = (String) component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
+ DojoUtils.addMainInclude(context, component, javascriptLocation, new DojoConfig());
+ DojoUtils.addRequire(context, component, "dojo.event.*");
+ // not required - and results in an error
+ // DojoUtils.addRequire(context, component, "dojo.io.bind");
+
+ AddResource addResource = AddResourceFactory.getInstance(context);
+
+ addResource.addJavaScriptAtPosition(context,
+ AddResource.HEADER_BEGIN, AjaxChildComboBox.class, "javascript/ajaxChildComboBox.js");
+ }
+
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException
+ {
+ RendererUtils.checkParamValidity(context, component, AjaxChildComboBox.class);
+
+ AjaxChildComboBox childComboBox = (AjaxChildComboBox) component;
+
+ super.encodeEnd(context, component);
+
+ String clientId = component.getClientId(context);
+
+ UIComponent parentComboBox = this.getParentComboBox(childComboBox);
+ if (parentComboBox == null)
+ {
+ log.error("Could not find parent combo box for AjaxChildComboBox " +
+ childComboBox.getClientId(context));
+ return;
+ }
+
+ encodeJavascript(context, component);
+
+ ResponseWriter writer = context.getResponseWriter();
+
+ // Begin: Write out the javascript that hooks up this component with the
+ // parent combo-box
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+
+ writer.write("var parentCombo = document.getElementById('" +
+ parentComboBox.getClientId(context) + "');");
+ HtmlRendererUtils.writePrettyLineSeparator(context);
+ writer.write("dojo.event.connect(parentCombo, 'onchange', function(evt) { ");
+ HtmlRendererUtils.writePrettyLineSeparator(context);
+ writer.write("var targetElement = evt.target;");
+ writer.write("var targetValue = targetElement.options[targetElement.selectedIndex].value;");
+ HtmlRendererUtils.writePrettyLineSeparator(context);
+ writer.write("reloadChildComboBox('" + clientId + "', targetValue);");
+ HtmlRendererUtils.writePrettyLineSeparator(context);
+ writer.write("});");
+ writer.endElement(HTML.SCRIPT_ELEM);
+ // End: Javascript
+ }
+
+
+ // creates the XML response that is sent back to the browser
+ public void encodeAjax(FacesContext context, UIComponent uiComponent)
+ throws IOException
+ {
+
+ String parentValue = (String) context.getExternalContext().
+ getRequestParameterMap().get("parentValue");
+
+ ServletResponse response = (ServletResponse) context.getExternalContext().getResponse();
+ PrintWriter writer = response.getWriter();
+
+ StringBuffer xml = new StringBuffer();
+
+ MethodExpression mb = ((AjaxChildComboBox) uiComponent).getAjaxSelectItemsMethod();
+ SelectItem[] options = (SelectItem[])
+ mb.invoke(context.getELContext(), new Object[]{parentValue});
+
+ xml.append("<?xml version=\"1.0\"?>\n");
+ xml.append("<response>\n");
+ for (int i = 0; i < options.length; i++)
+ {
+ xml.append(BEGIN_OPTION);
+ xml.append(BEGIN_OPTION_TEXT).append(options[i].getLabel()).append(END_OPTION_TEXT);
+ xml.append(BEGIN_OPTION_VALUE).append(options[i].getValue()).append(END_OPTION_VALUE);
+ xml.append(END_OPTION);
+ }
+ xml.append("</response>");
+
+ writer.write(xml.toString());
+
+ }
+
+ private UIComponent getParentComboBox(AjaxChildComboBox comboBox)
+ {
+ String parentId = comboBox.getParentComboBox();
+
+ UIComponent parentComboBox = comboBox.findComponent(parentId);
+ if (parentComboBox != null)
+ {
+ return parentComboBox;
+ }
+
+ // try searching from the very root of the component tree
+ return comboBox.findComponent(UINamingContainer.SEPARATOR_CHAR + parentId);
+ }
+}
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java?rev=662966&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java (added)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java Tue Jun 3 20:37:59 2008
@@ -0,0 +1,540 @@
+/*
+ * 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 org.apache.myfaces.custom.comparetovalidator;
+
+import java.util.Comparator;
+
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.Renderer;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.myfaces.shared_tomahawk.util.MessageUtils;
+import org.apache.myfaces.validator.ValidatorBase;
+
+/**
+ *
+ * Validates this component against another component.
+ *
+ * Specify the foreign component with the for={foreign-component-id} attribute.
+ *
+ * Valid operator attribute values:
+ *
+ * equals: eq, ==, =,
+ * not equals: ne, !=,
+ * greater than: gt, >,
+ * less than: lt, <,
+ * greater than or equals: ge, >=,
+ * less than or equals: le, <=
+ *
+ * If the comparator attribute is specified, the component values are compared
+ * using the specified java.util.Comparator object.
+ * If no comparator is specified, the component values must implement Comparable
+ * and are compared using compareTo().
+ * If either value or foreign value does not implement Comparable and no Comparator
+ * is specified, validation always succeeds.
+ *
+ * Put this validator on the bottom-most component to insure that
+ * the foreign component's value has been converted and validated first.
+ *
+ * However, this validator will attempt to convert and validate the foreign
+ * component's value if this has not already occurred. This process may not
+ * be identical to the standard JSF conversion and validation process.
+ *
+ * The validation error message key is currently hardcoded as
+ *
+ * "{0} value <{1}> must be {2} {3} value <{4}>"
+ *
+ * where {0} is the parent component id,
+ * {1} is the parent component value,
+ * {2} is the operator name,
+ * {3} is the foreign component id, and
+ * {4} is the foreign component value.
+ *
+ * The alternateOperatorName attribute can specify a custom operator name.
+ * For example, use "after" instead of "greater than" when comparing dates.
+ *
+ * The message attribute can specify an alternate validation error message key.
+ * For example, use "{0} must be {2} {3}" to remove values from the message.
+ *
+ *
+ * faces-config.xml configuration:
+ *
+ * <validator>
+ * <description>CompareTo validator</description>
+ * <validator-id>org.apache.myfaces.validator.CompareTo</validator-id>
+ * <validator-class>org.apache.myfaces.custom.comparetovalidator.CompareToValidator</validator-class>
+ * </validator>
+ *
+ *
+ * Facelets configuration (inside a taglib.xml file):
+ *
+ * <tag>
+ * <tag-name>compareToValidator</tag-name>
+ * <validator>
+ * <validator-id>org.apache.myfaces.validator.CompareTo</validator-id>
+ * </validator>
+ * </tag>
+ *
+ *
+ * Example usage:
+ *
+ * <t:inputCalendar id="startDate"/>
+ * <t:inputCalendar id="endDate">
+ * <sandbox:compareToValidator operator="gt" for="startDate" />
+ * <sandbox:compareToValidator operator="gt" for="startDate" message="Start date must be before end date." />
+ * <sandbox:compareToValidator operator="gt" for="startDate" message="{0} must be {2} {3}" />
+ * <sandbox:compareToValidator operator="gt" for="startDate" alternateOperatorName="after" />
+ * <sandbox:compareToValidator operator="gt" for="startDate" message="{0} must be {2} {3}" alternateOperatorName="after" />
+ * <sandbox:compareToValidator operator="gt" for="startDate" comparator="#{dateComparator}" />
+ * <t:inputCalendar>
+ *
+ *
+ * Known issues:
+ * - Operator names should be localized.
+ * - The default message key should be localized.
+ * - Perhaps an exception should be thrown if the two values are not Comparable and no Comparator is specified.
+ *
+ * @JSFValidator
+ * name = "s:validateCompareTo"
+ * tagClass = "org.apache.myfaces.custom.comparetovalidator.ValidateCompareToTag"
+ * tagSuperclass = "org.apache.myfaces.validator.ValidatorBaseTag"
+ * serialuidtag = "-8879289182242196266L"
+ *
+ * @JSFJspProperty name = "message" inheritedTag="true" returnType = "java.lang.String" longDesc = "alternate validation error message format string"
+ *
+ * @author Mike Kienenberger (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class CompareToValidator extends ValidatorBase {
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.validator.CompareTo";
+
+ /**
+ * <p>The message identifier of the {@link FacesMessage} to be created if
+ * the comparison check fails.</p>
+ */
+ // public static final String COMPARE_TO_MESSAGE_ID = "org.apache.myfaces.CompareTo.INVALID";
+ public static final String COMPARE_TO_MESSAGE_ID = "{0} value <{1}> must be {2} {3} value <{4}>";
+
+ public CompareToValidator(){
+ super();
+ }
+
+ //the foreign component_id on which the validation is based.
+ protected String _foreignComponentName = null;
+ protected String _operator = null;
+ protected Object _comparator = null;
+ protected String _alternateOperatorName = null;
+
+ public static final String OPERATOR_EQUALS = "eq";
+ public static final String OPERATOR_NOT_EQUALS = "ne";
+ public static final String OPERATOR_GREATER_THAN = "gt";
+ public static final String OPERATOR_LESS_THAN = "lt";
+ public static final String OPERATOR_GREATER_THAN_OR_EQUALS = "ge";
+ public static final String OPERATOR_LESS_THAN_OR_EQUALS = "le";
+
+ public static final String OPERATOR_EQUALS_ALT = "==";
+ public static final String OPERATOR_NOT_EQUALS_ALT = "!=";
+ public static final String OPERATOR_GREATER_THAN_ALT = ">";
+ public static final String OPERATOR_LESS_THAN_ALT = "<";
+ public static final String OPERATOR_GREATER_THAN_OR_EQUALS_ALT = ">=";
+ public static final String OPERATOR_LESS_THAN_OR_EQUALS_ALT = "<=";
+
+ public static final String OPERATOR_EQUALS_ALT2 = "=";
+
+ protected String getOperatorForString(String operatorSpecified)
+ {
+ if (OPERATOR_EQUALS.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_EQUALS;
+ else if (OPERATOR_NOT_EQUALS.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_NOT_EQUALS;
+ else if (OPERATOR_GREATER_THAN.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_GREATER_THAN;
+ else if (OPERATOR_LESS_THAN.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_LESS_THAN;
+ else if (OPERATOR_GREATER_THAN_OR_EQUALS.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_GREATER_THAN_OR_EQUALS;
+ else if (OPERATOR_LESS_THAN_OR_EQUALS.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_LESS_THAN_OR_EQUALS;
+
+ else if (OPERATOR_EQUALS_ALT.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_EQUALS;
+ else if (OPERATOR_NOT_EQUALS_ALT.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_NOT_EQUALS;
+ else if (OPERATOR_GREATER_THAN_ALT.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_GREATER_THAN;
+ else if (OPERATOR_LESS_THAN_ALT.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_LESS_THAN;
+ else if (OPERATOR_GREATER_THAN_OR_EQUALS_ALT.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_GREATER_THAN_OR_EQUALS;
+ else if (OPERATOR_LESS_THAN_OR_EQUALS_ALT.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_LESS_THAN_OR_EQUALS;
+
+ else if (OPERATOR_EQUALS_ALT2.equalsIgnoreCase(operatorSpecified))
+ return OPERATOR_EQUALS;
+
+ throw new IllegalStateException("Operator has unknown value of '" + operatorSpecified + "'");
+ }
+
+ protected String nameForOperator(String operator)
+ {
+ if (OPERATOR_EQUALS == operator)
+ return "equal to";
+ else if (OPERATOR_NOT_EQUALS == operator)
+ return "inequal to";
+ else if (OPERATOR_GREATER_THAN == operator)
+ return "greater than";
+ else if (OPERATOR_LESS_THAN == operator)
+ return "less than";
+ else if (OPERATOR_GREATER_THAN_OR_EQUALS == operator)
+ return "greater than or equal to";
+ else if (OPERATOR_LESS_THAN_OR_EQUALS == operator)
+ return "less than or equal to";
+
+ throw new IllegalStateException("Operator has unknown value of '" + operator + "'");
+ }
+
+ protected boolean validateOperatorOnComparisonResult(String operator, int result)
+ {
+ if (OPERATOR_EQUALS == operator)
+ return result == 0;
+ else if (OPERATOR_NOT_EQUALS == operator)
+ return result != 0;
+ else if (OPERATOR_GREATER_THAN == operator)
+ return result > 0;
+ else if (OPERATOR_LESS_THAN == operator)
+ return result < 0;
+ else if (OPERATOR_GREATER_THAN_OR_EQUALS == operator)
+ return result >= 0;
+ else if (OPERATOR_LESS_THAN_OR_EQUALS == operator)
+ return result <= 0;
+
+ throw new IllegalStateException("Operator has unknown value of '" + operator + "'");
+ }
+
+ public void validate(
+ FacesContext facesContext,
+ UIComponent uiComponent,
+ Object value)
+ throws ValidatorException {
+
+ if (facesContext == null) throw new NullPointerException("facesContext");
+ if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+ // Don't perform validation if the value is null
+ if (value == null)
+ {
+ return;
+ }
+
+ String foreignComponentName = getFor();
+
+ UIComponent foreignComponent = (UIComponent) uiComponent.getParent().findComponent(foreignComponentName);
+ if(foreignComponent == null)
+ throw new FacesException("Unable to find component '" + foreignComponentName + "' (calling findComponent on component '" + uiComponent.getId() + "')");
+
+ if(false == foreignComponent instanceof EditableValueHolder)
+ throw new FacesException("Component '" + foreignComponent.getId() + "' does not implement EditableValueHolder");
+ EditableValueHolder foreignEditableValueHolder = (EditableValueHolder)foreignComponent;
+
+ if (foreignEditableValueHolder.isRequired() && foreignEditableValueHolder.getValue()== null ) {
+ return;
+ }
+
+ Object foreignValue;
+ if (foreignEditableValueHolder.isValid())
+ {
+ foreignValue = foreignEditableValueHolder.getValue();
+ }
+ else
+ {
+ foreignValue = getConvertedValueNonValid(facesContext, foreignComponent);
+ }
+
+ // Don't perform validation if the foreign value is null
+ if (null == foreignValue)
+ {
+ return;
+ }
+
+ String operator = getOperatorForString(getOperator());
+
+ String alternateOperatorName = getAlternateOperatorName();
+ Object[] args = {
+ uiComponent.getId(),
+ value.toString(),
+ (alternateOperatorName == null) ? nameForOperator(operator) : alternateOperatorName,
+ foreignComponent.getId(),
+ (foreignValue == null) ? foreignComponent.getId() : foreignValue.toString()
+ };
+
+ String message = getMessage();
+ if (null == message) message = COMPARE_TO_MESSAGE_ID;
+
+ Comparator comparator = createComparator();
+
+ if (null != comparator)
+ {
+ if (false == validateOperatorOnComparisonResult(operator, comparator.compare(value, foreignValue)))
+ {
+ throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message, args));
+ }
+ }
+ else if ( (value instanceof Comparable) && (foreignValue instanceof Comparable) )
+ {
+ try
+ {
+ if (false == validateOperatorOnComparisonResult(operator, ((Comparable)value).compareTo(foreignValue)))
+ {
+ throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message, args));
+ }
+ }
+ catch (RuntimeException exception)
+ {
+ if (exception instanceof ValidatorException)
+ {
+ throw exception;
+ }
+ else
+ {
+ throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message + ": " + exception.getLocalizedMessage(), args));
+ }
+ }
+ }
+ else if (value instanceof Comparable)
+ {
+ throw new ClassCastException(getClassCastExceptionMessage(foreignComponent.getId(), Comparable.class, foreignValue));
+ }
+ else if (foreignValue instanceof Comparable)
+ {
+ throw new ClassCastException(getClassCastExceptionMessage(uiComponent.getId(), Comparable.class, value));
+ }
+ }
+
+ protected String getClassCastExceptionMessage(String name, Class clazz, Object object)
+ {
+ if (null == object)
+ return name + " must be type " + clazz + " but is null";
+ else return name + " must be type " + clazz + " but is type " + object.getClass();
+ }
+
+ protected Comparator createComparator()
+ {
+ Object comparator = getComparator();
+
+ if (null == comparator) return null;
+
+ if (false == comparator instanceof Comparator)
+ {
+ throw new ClassCastException(getClassCastExceptionMessage("comparator", Comparator.class, comparator));
+ }
+
+ return (Comparator)comparator;
+ }
+
+ // -------------------------------------------------------- GETTER & SETTER
+
+ /**
+ * The JSF id of the component with which to compare values.
+ *
+ * @JSFProperty
+ * @return the foreign component_id, on which a value should be validated
+ */
+ public String getFor() {
+ if (_foreignComponentName != null) return _foreignComponentName;
+ ValueExpression vb = getValueExpression("for");
+ return vb != null ? (String) vb.getValue(getFacesContext().getELContext()) : null;
+ }
+
+ /**
+ * @param string the foreign component_id, on which a value should be validated
+ */
+ public void setFor(String string) {
+ _foreignComponentName = string;
+ }
+
+ /**
+ * Operator for comparison: equals: eq, ==, =, not equals: ne, !=, greater than: gt, >, less than: lt, <, greater than or equals: ge, >=, less than or equals: le, <=
+ *
+ * @JSFProperty
+ * @return
+ */
+ public String getOperator()
+ {
+ if (_operator != null) return _operator;
+ ValueExpression vb = getValueExpression("operator");
+ return vb != null ? (String) vb.getValue(getFacesContext().getELContext()) : null;
+ }
+
+ public void setOperator(String operator)
+ {
+ this._operator = operator;
+ }
+
+ /**
+ * Value binding for an alternate java.util.Comparator object if component
+ * values don't implement Comparable
+ *
+ * @JSFProperty
+ * @return
+ */
+ public Object getComparator()
+ {
+ if (_comparator != null) return _comparator;
+ ValueExpression vb = getValueExpression("comparator");
+ return vb != null ? (Comparator)vb.getValue(getFacesContext().getELContext()) : null;
+ }
+
+ public void setComparator(Object comparator)
+ {
+ this._comparator = comparator;
+ }
+
+ /**
+ * custom operator name in error message (ie "after" instead of "greater than" for dates)
+ *
+ * @JSFProperty
+ * @return
+ */
+ public String getAlternateOperatorName()
+ {
+ if (_alternateOperatorName != null) return _alternateOperatorName;
+ ValueExpression vb = getValueExpression("alternateOperatorName");
+ return vb != null ? (String) vb.getValue(getFacesContext().getELContext()) : null;
+ }
+
+ public void setAlternateOperatorName(String alternateOperatorName)
+ {
+ this._alternateOperatorName = alternateOperatorName;
+ }
+
+ // -------------------------------------------------------- StateholderIF
+
+ public Object saveState(FacesContext context) {
+ Object values[] = new Object[5];
+ values[0] = super.saveState(context);
+ values[1] = _foreignComponentName;
+ values[2] = _operator;
+ values[3] = _comparator;
+ values[4] = _alternateOperatorName;
+ return values;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object values[] = (Object[])state;
+ super.restoreState(context, values[0]);
+ _foreignComponentName = (String) values[1];
+ _operator = (String) values[2];
+ _comparator = values[3];
+ _alternateOperatorName = (String) values[4];
+ }
+
+ // ---------------- Borrowed to convert foreign submitted values
+
+ protected Renderer getRenderer(FacesContext context, UIComponent foreignComponent)
+ {
+ if (context == null) throw new NullPointerException("context");
+ String rendererType = foreignComponent.getRendererType();
+ if (rendererType == null) return null;
+ String renderKitId = context.getViewRoot().getRenderKitId();
+ RenderKitFactory rkf = (RenderKitFactory)FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKit renderKit = rkf.getRenderKit(context, renderKitId);
+ Renderer renderer = renderKit.getRenderer(foreignComponent.getFamily(), rendererType);
+ if (renderer == null)
+ {
+ getFacesContext().getExternalContext().log("No Renderer found for component " + foreignComponent + " (component-family=" + foreignComponent.getFamily() + ", renderer-type=" + rendererType + ")");
+ }
+ return renderer;
+ }
+
+ protected Converter findUIOutputConverter(FacesContext facesContext, UIComponent component)
+ {
+ Converter converter = ((EditableValueHolder)component).getConverter();
+ if (converter != null) return converter;
+
+ //Try to find out by value binding
+ ValueExpression vb = component.getValueExpression("value");
+ if (vb == null) return null;
+
+ Class valueType = vb.getType(facesContext.getELContext());
+ if (valueType == null) return null;
+
+ if (String.class.equals(valueType)) return null; //No converter needed for String type
+ if (Object.class.equals(valueType)) return null; //There is no converter for Object class
+
+ try
+ {
+ return facesContext.getApplication().createConverter(valueType);
+ }
+ catch (FacesException e)
+ {
+ getFacesContext().getExternalContext().log("No Converter for type " + valueType.getName() + " found", e);
+ return null;
+ }
+ }
+
+
+ // --------------------- borrowed and modified from UIInput ------------
+
+ protected Object getConvertedValueNonValid(FacesContext facesContext, UIComponent component)
+ {
+ Object componentValueObject;
+ Object submittedValue = ((EditableValueHolder) component).getSubmittedValue();
+ if (submittedValue == null)
+ {
+ componentValueObject = null;
+ }
+ else
+ {
+ try
+ {
+ Renderer renderer = getRenderer(facesContext, component);
+ if (renderer != null)
+ {
+ componentValueObject = renderer.getConvertedValue(facesContext, component, submittedValue);
+ }
+ else if (submittedValue instanceof String)
+ {
+ Converter converter = findUIOutputConverter(facesContext, component);
+ if (converter != null)
+ {
+ componentValueObject = converter.getAsObject(facesContext, component, (String)submittedValue);
+ }
+ }
+ }
+ catch (ConverterException e)
+ {
+ }
+ componentValueObject = submittedValue;
+ }
+ return componentValueObject;
+ }
+}
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/bigtest/tomahawk12_trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL