Author: alexsmirnov
Date: 2008-09-23 13:16:55 -0400 (Tue, 23 Sep 2008)
New Revision: 10544
Added:
trunk/samples/seamIntegration/profiles.xml
Modified:
trunk/framework/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java
trunk/samples/beanValidatorSample/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/beanValidatorSample/src/main/webapp/pages/index.xhtml
trunk/samples/seamIntegration/pom.xml
trunk/samples/seamIntegration/src/main/webapp/WEB-INF/components.xml
trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml
trunk/ui/beanValidator/pom.xml
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
Log:
Move getValidJavaScriptName method to the ScriptUtils.
Fix Seam sample.
Modified: trunk/framework/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java 2008-09-23
16:19:50 UTC (rev 10543)
+++ trunk/framework/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java 2008-09-23
17:16:55 UTC (rev 10544)
@@ -22,6 +22,7 @@
package org.ajax4jsf.javascript;
import java.beans.PropertyDescriptor;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Iterator;
@@ -161,4 +162,56 @@
}
}
}
+
+ public static String getValidJavascriptName(String s) {
+
+ StringBuffer buf = null;
+ for (int i = 0, len = s.length(); i < len; i++) {
+ char c = s.charAt(i);
+
+ if (Character.isLetterOrDigit(c)||c=='_' ) {
+ // allowed char
+ if (buf != null)
+ buf.append(c);
+ } else {
+ if (buf == null) {
+ buf = new StringBuffer(s.length() + 10);
+ buf.append(s.substring(0, i));
+ }
+
+ buf.append('_');
+ if (c < 16) {
+ // pad single hex digit values with '0' on the left
+ buf.append('0');
+ }
+
+ if (c < 128) {
+ // first 128 chars match their byte representation in UTF-8
+ buf.append(Integer.toHexString(c).toUpperCase());
+ } else {
+ byte[] bytes;
+ try {
+ bytes = Character.toString(c).getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+
+ for (int j = 0; j < bytes.length; j++) {
+ int intVal = bytes[j];
+ if (intVal < 0) {
+ // intVal will be >= 128
+ intVal = 256 + intVal;
+ } else if (intVal < 16) {
+ // pad single hex digit values with '0' on the left
+ buf.append('0');
+ }
+ buf.append(Integer.toHexString(intVal).toUpperCase());
+ }
+ }
+ }
+
+ }
+
+ return buf == null ? s : buf.toString();
+ }
}
Modified: trunk/samples/beanValidatorSample/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/beanValidatorSample/src/main/webapp/WEB-INF/faces-config.xml 2008-09-23
16:19:50 UTC (rev 10543)
+++ trunk/samples/beanValidatorSample/src/main/webapp/WEB-INF/faces-config.xml 2008-09-23
17:16:55 UTC (rev 10544)
@@ -17,4 +17,9 @@
<managed-bean-class>org.richfaces.LengthBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>minMaxBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.MinMaxBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
</faces-config>
Modified: trunk/samples/beanValidatorSample/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/samples/beanValidatorSample/src/main/webapp/pages/index.xhtml 2008-09-23
16:19:50 UTC (rev 10543)
+++ trunk/samples/beanValidatorSample/src/main/webapp/pages/index.xhtml 2008-09-23
17:16:55 UTC (rev 10544)
@@ -18,12 +18,23 @@
<f:facet name="header">
<h:outputText>Single input field with label and message. Validated by AJAX on
every char.</h:outputText>
</f:facet>
+ <h:panelGrid columns="3">
<h:outputLabel for="ltext"
value="#{lengthBean.textDescription}" />
- <h:inputText id="ltext" value="#{lengthBean.text}">
+ <h:inputText id="ltext" value="#{lengthBean.text}"
label="3-letter text">
<v:ajaxValidator event="onkeyup" summary="Invalid Id"/>
</h:inputText>
<rich:message for="ltext" showDetail="true"
showSummary="true" />
+ <h:outputLabel for="mtext" value="#{minMaxBean.intDescription}"
/>
+ <h:inputText id="mtext" value="#{minMaxBean.intValue}"
label="value">
+ <v:ajaxValidator event="onkeyup" summary="Invalid value"/>
+ </h:inputText>
+ <rich:message for="mtext" showDetail="true"
showSummary="true" />
+ </h:panelGrid>
+ <h:commandButton value="Submit"></h:commandButton>
</rich:panel>
+ <rich:messages />
+ </h:form>
+ <h:form id="form1">
<h2>Input fields with label and message in the JSF dataTable.
Each field validated by AJAX on 'onblur' event</h2>
<v:graphValidator value="#{data}">
Modified: trunk/samples/seamIntegration/pom.xml
===================================================================
--- trunk/samples/seamIntegration/pom.xml 2008-09-23 16:19:50 UTC (rev 10543)
+++ trunk/samples/seamIntegration/pom.xml 2008-09-23 17:16:55 UTC (rev 10544)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
@@ -12,6 +12,9 @@
<artifactId>seamIntegration</artifactId>
<packaging>war</packaging>
<name>seamIntegration Maven Webapp</name>
+ <properties>
+ <seam.version>2.1.0-SNAPSHOT</seam.version>
+ </properties>
<build>
<finalName>seamIntegration</finalName>
<plugins>
@@ -70,31 +73,33 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jcl</artifactId>
<version>1.4.2</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
- <version>3.1.0.CR2</version>
+ <version>3.1.0.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam</artifactId>
- <version>2.0.2.GA</version>
+ <version>${seam.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam-ui</artifactId>
- <version>2.0.2.GA</version>
+ <version>${seam.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam-ioc</artifactId>
- <version>2.0.2.GA</version>
+ <version>${seam.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam-debug</artifactId>
- <version>2.0.2.GA</version>
+ <version>${seam.version}</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
Added: trunk/samples/seamIntegration/profiles.xml
===================================================================
--- trunk/samples/seamIntegration/profiles.xml (rev 0)
+++ trunk/samples/seamIntegration/profiles.xml 2008-09-23 17:16:55 UTC (rev 10544)
@@ -0,0 +1,26 @@
+<?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. * * $Id: profiles.xml
+ 495383 2007-01-11 21:31:37Z rahul $ */
+ -->
+<profilesXml>
+ <profiles>
+ <profile>
+ <id>seam-devel</id>
+ <properties>
+ <seam.version>2.1.0-SNAPSHOT</seam.version>
+ </properties>
+ </profile>
+ </profiles>
+</profilesXml>
\ No newline at end of file
Property changes on: trunk/samples/seamIntegration/profiles.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/samples/seamIntegration/src/main/webapp/WEB-INF/components.xml
===================================================================
--- trunk/samples/seamIntegration/src/main/webapp/WEB-INF/components.xml 2008-09-23
16:19:50 UTC (rev 10543)
+++ trunk/samples/seamIntegration/src/main/webapp/WEB-INF/components.xml 2008-09-23
17:16:55 UTC (rev 10544)
@@ -14,7 +14,7 @@
http://jboss.com/products/seam/bpm
http://jboss.com/products/seam/bpm-2.0.xsd
http://jboss.com/products/seam/security
http://jboss.com/products/seam/security-2.0.xsd
http://jboss.com/products/seam/mail
http://jboss.com/products/seam/mail-2.0.xsd
-
http://jboss.com/products/seam/transaction
http://jboss.com/products/seam/transaction-2.1.xsd
+
http://jboss.com/products/seam/transaction
http://jboss.com/products/seam/transaction-2.0.xsd
http://jboss.com/products/seam/components
http://jboss.com/products/seam/components-2.0.xsd">
<core:init debug="true" /><!--
transaction-management-enabled="false" -->
Modified: trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml 2008-09-23 16:19:50 UTC
(rev 10543)
+++ trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml 2008-09-23 17:16:55 UTC
(rev 10544)
@@ -1,9 +1,10 @@
<?xml version="1.0" ?>
-<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
- version="2.4">
+<web-app version="2.5"
+
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-app_2_5.xsd">
+
<!-- Ajax4jsf -->
<context-param>
Modified: trunk/ui/beanValidator/pom.xml
===================================================================
--- trunk/ui/beanValidator/pom.xml 2008-09-23 16:19:50 UTC (rev 10543)
+++ trunk/ui/beanValidator/pom.xml 2008-09-23 17:16:55 UTC (rev 10544)
@@ -50,7 +50,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
- <version>3.1.0.CR1</version>
+ <version>3.1.0.GA</version>
<exclusions>
<!--
<exclusion> <artifactId>hibernate-core</artifactId>
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
===================================================================
---
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2008-09-23
16:19:50 UTC (rev 10543)
+++
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2008-09-23
17:16:55 UTC (rev 10544)
@@ -22,7 +22,6 @@
package org.ajax4jsf.renderkit.html;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@@ -38,6 +37,7 @@
import org.ajax4jsf.component.UIAjaxForm;
import org.ajax4jsf.event.AjaxEvent;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
@@ -300,7 +300,7 @@
script.append("\n}");
script.append("\n");
script.append("function
").append("clearFormHiddenParams_").append(
- getValidJavascriptName(formName));
+ ScriptUtils.getValidJavascriptName(formName));
script.append("(){").append(functionName).append("();}\n");
// MyFaces 1.1.5 clear form function name
@@ -335,59 +335,7 @@
* @return String
*/
public String getClearHiddenCommandFormParamsFunctionName(String formName) {
- return "clear_" + getValidJavascriptName(formName);
+ return "clear_" + ScriptUtils.getValidJavascriptName(formName);
}
- public String getValidJavascriptName(String s) {
-
- StringBuffer buf = null;
- for (int i = 0, len = s.length(); i < len; i++) {
- char c = s.charAt(i);
-
- if (Character.isLetterOrDigit(c)||c=='_' ) {
- // allowed char
- if (buf != null)
- buf.append(c);
- } else {
- if (buf == null) {
- buf = new StringBuffer(s.length() + 10);
- buf.append(s.substring(0, i));
- }
-
- buf.append('_');
- if (c < 16) {
- // pad single hex digit values with '0' on the left
- buf.append('0');
- }
-
- if (c < 128) {
- // first 128 chars match their byte representation in UTF-8
- buf.append(Integer.toHexString(c).toUpperCase());
- } else {
- byte[] bytes;
- try {
- bytes = Character.toString(c).getBytes("UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
-
- for (int j = 0; j < bytes.length; j++) {
- int intVal = bytes[j];
- if (intVal < 0) {
- // intVal will be >= 128
- intVal = 256 + intVal;
- } else if (intVal < 16) {
- // pad single hex digit values with '0' on the left
- buf.append('0');
- }
- buf.append(Integer.toHexString(intVal).toUpperCase());
- }
- }
- }
-
- }
-
- return buf == null ? s : buf.toString();
- }
-
}