You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ca...@apache.org on 2007/04/20 14:08:36 UTC
svn commit: r530757 - in /myfaces/tomahawk/trunk/sandbox/core/src/main:
java/org/apache/myfaces/convert/ex/ resources-facesconfig/META-INF/
resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/
Author: cagatay
Date: Fri Apr 20 05:08:35 2007
New Revision: 530757
URL: http://svn.apache.org/viewvc?view=rev&rev=530757
Log:
Add extended longconverter and shortconverter with client side capability
Added:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/LongConverter.java (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/ShortConverter.java (with props)
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/converters.js
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/LongConverter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/LongConverter.java?view=auto&rev=530757
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/LongConverter.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/LongConverter.java Fri Apr 20 05:08:35 2007
@@ -0,0 +1,36 @@
+/*
+ * 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.convert.ex;
+
+import org.apache.myfaces.custom.clientvalidation.common.ClientConverter;
+
+/**
+ * @author cagatay (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class LongConverter extends javax.faces.convert.LongConverter implements ClientConverter{
+
+ public String getScriptFunction() {
+ return "tomahawk.LongConverter()";
+ }
+
+ public String getScriptResource() {
+ return null;
+ }
+}
\ No newline at end of file
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/LongConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/LongConverter.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/ShortConverter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/ShortConverter.java?view=auto&rev=530757
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/ShortConverter.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/ShortConverter.java Fri Apr 20 05:08:35 2007
@@ -0,0 +1,36 @@
+/*
+ * 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.convert.ex;
+
+import org.apache.myfaces.custom.clientvalidation.common.ClientConverter;
+
+/**
+ * @author cagatay (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class ShortConverter extends javax.faces.convert.ShortConverter implements ClientConverter{
+
+ public String getScriptFunction() {
+ return "tomahawk.ShortConverter()";
+ }
+
+ public String getScriptResource() {
+ return null;
+ }
+}
\ No newline at end of file
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/ShortConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/convert/ex/ShortConverter.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml?view=diff&rev=530757&r1=530756&r2=530757
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources-facesconfig/META-INF/faces-config.xml Fri Apr 20 05:08:35 2007
@@ -649,6 +649,22 @@
<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>
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/converters.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/converters.js?view=diff&rev=530757&r1=530756&r2=530757
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/converters.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/clientvalidation/validationscript/resource/converters.js Fri Apr 20 05:08:35 2007
@@ -89,4 +89,54 @@
}
return null;
}
+}
+
+tomahawk.LongConverter = function() {
+
+ this.CONVERSION_MESSAGE_ID = "javax.faces.convert.LongConverter.CONVERSION";
+
+ this.getAsObject = function(context,uiinput,value) {
+
+ if( value != null ) {
+ //TODO trim
+ if( value.length > 0) {
+ var integerRegExp = /^(\+|-)?\d+$/;
+ var isInteger = integerRegExp.test(value);
+ if( !isInteger ) {
+ var facesMessage = tomahawk.MessageUtils.getMessage(tomahawk.FacesMessage.SEVERITY_ERROR,this.CONVERSION_MESSAGE_ID,new Array(uiinput.id,value))
+ throw new tomahawk.ConverterException( facesMessage );
+ }
+ else {
+ var convertedValue = parseInt( value );
+ return convertedValue;
+ }
+ }
+ }
+ return null;
+ }
+}
+
+tomahawk.ShortConverter = function() {
+
+ this.CONVERSION_MESSAGE_ID = "javax.faces.convert.ShortConverter.CONVERSION";
+
+ this.getAsObject = function(context,uiinput,value) {
+
+ if( value != null ) {
+ //TODO trim
+ if( value.length > 0) {
+ var integerRegExp = /^(\+|-)?\d+$/;
+ var isInteger = integerRegExp.test(value);
+ if( !isInteger ) {
+ var facesMessage = tomahawk.MessageUtils.getMessage(tomahawk.FacesMessage.SEVERITY_ERROR,this.CONVERSION_MESSAGE_ID,new Array(uiinput.id,value))
+ throw new tomahawk.ConverterException( facesMessage );
+ }
+ else {
+ var convertedValue = parseInt( value );
+ return convertedValue;
+ }
+ }
+ }
+ return null;
+ }
}