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/07/02 07:31:52 UTC
svn commit: r673285 [2/3] - in /myfaces/commons/branches/jsf_11: ./
myfaces-commons-converters/
myfaces-commons-converters/src/main/java/org/apache/myfaces/commons/converter/
myfaces-commons-converters/src/main/resources/META-INF/
myfaces-commons-examp...
Added: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/home.jsp?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/home.jsp (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/home.jsp Tue Jul 1 22:31:50 2008
@@ -0,0 +1,57 @@
+<%@ page import="java.math.BigDecimal,
+ java.util.Date"%>
+<%@ page session="false" contentType="text/html;charset=utf-8"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<html>
+
+<!--
+/*
+ * 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.
+ */
+//-->
+
+<%@include file="inc/head.inc"%>
+
+<body>
+
+<f:view>
+
+ <f:loadBundle
+ basename="org.apache.myfaces.examples.resource.example_messages"
+ var="example_messages" />
+
+ <h:form>
+ <h:panelGrid>
+ <h:outputLink value="validate.jsf">
+ <f:verbatim>Validate Email, Credit Card, Regex</f:verbatim>
+ </h:outputLink>
+ <h:outputLink value="validateCompareTo.jsf">
+ <f:verbatim>ValidateCompareTo</f:verbatim>
+ </h:outputLink>
+ <h:outputLink value="validateCSV.jsf">
+ <f:verbatim>ValidateCSV</f:verbatim>
+ </h:outputLink>
+ </h:panelGrid>
+ </h:form>
+
+</f:view>
+
+</body>
+
+</html>
\ No newline at end of file
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/home.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/home.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/inc/head.inc
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/inc/head.inc?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/inc/head.inc (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/inc/head.inc Tue Jul 1 22:31:50 2008
@@ -0,0 +1,5 @@
+<head>
+ <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8" />
+ <title>MyFaces - the free JSF Implementation</title>
+ <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/basic.css" />
+</head>
Added: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/inc/page_footer.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/inc/page_footer.jsp?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/inc/page_footer.jsp (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/inc/page_footer.jsp Tue Jul 1 22:31:50 2008
@@ -0,0 +1,4 @@
+<br/>
+<br/>
+
+<a href="home.jsf">[HOME]</a>
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/inc/page_footer.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/inc/page_footer.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/index.jsp?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/index.jsp (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/index.jsp Tue Jul 1 22:31:50 2008
@@ -0,0 +1,4 @@
+<%@ page session="false"%>
+<%
+response.sendRedirect("home.jsf");
+%>
\ No newline at end of file
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/index.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validate.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validate.jsp?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validate.jsp (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validate.jsp Tue Jul 1 22:31:50 2008
@@ -0,0 +1,91 @@
+<%@ page import="java.math.BigDecimal,
+ java.util.Date" %>
+<%@ page session="false" contentType="text/html;charset=utf-8" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://myfaces.apache.org/commons/converters" prefix="mcc" %>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators" prefix="mcv" %>
+<html>
+
+<%@ include file="inc/head.inc" %>
+
+<!--
+/*
+ * 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.
+ */
+//-->
+
+<body>
+
+<!--
+managed beans used:
+ validateForm
+-->
+
+<f:view>
+
+ <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
+
+ <h:panelGroup id="body">
+
+ <h:messages showDetail="true" showSummary="false"/>
+
+ <h:form id="form1">
+ <h:panelGrid columns="3">
+
+ <h:outputLabel for="email" value="#{example_messages['validate_email']}"/>
+ <h:inputText id="email" value="#{validateForm.email}" required="true">
+ <f:validator validatorId="org.apache.myfaces.commons.validator.Email"/>
+ </h:inputText>
+ <h:message id="emailError" for="email" styleClass="error"/>
+
+ <h:outputLabel for="email2" value="#{example_messages['validate_email']}2"/>
+ <h:inputText id="email2" value="#{validateForm.email2}" required="true">
+ <mcv:validateEmail detailMessage="Not a valid email address."/>
+ </h:inputText>
+ <h:message id="emailError2" for="email2" styleClass="error"/>
+
+ <h:outputLabel for="creditCardNumber" value="#{example_messages['validate_credit']}"/>
+ <h:inputText id="creditCardNumber" value="#{validateForm.creditCardNumber}" required="true">
+ <mcv:validateCreditCard detailMessage='#{"{0} is not a valid credit card number."}'/>
+ </h:inputText>
+ <h:message id="creditCardNumberError" for="creditCardNumber" styleClass="error"/>
+
+ <h:outputLabel for="regExprValue" value="#{example_messages['validate_regexp']}"/>
+ <h:inputText id="regExprValue" value="#{validateForm.regExpr}" required="true">
+ <mcv:validateRegExpr pattern="[bcr]at" detailMessage='#{"{0} is not valid in this field." }'/>
+ </h:inputText>
+ <h:message id="regExprValueError" for="regExprValue" styleClass="error"/>
+
+ <h:panelGroup/>
+ <h:commandButton id="validateButton" value="#{example_messages['button_submit']}"
+ action="#{validateForm.submit}"/>
+ <h:panelGroup/>
+
+ </h:panelGrid>
+ </h:form>
+
+ </h:panelGroup>
+
+</f:view>
+
+<%@ include file="inc/page_footer.jsp" %>
+
+</body>
+
+</html>
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validate.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validate.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCSV.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCSV.jsp?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCSV.jsp (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCSV.jsp Tue Jul 1 22:31:50 2008
@@ -0,0 +1,77 @@
+<%@ page session="false" contentType="text/html;charset=utf-8"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://myfaces.apache.org/commons/converters" prefix="mcc" %>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators" prefix="mcv" %>
+
+<html>
+
+<%@include file="inc/head.inc" %>
+
+<!--
+/*
+ * 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.
+ */
+//-->
+
+<body>
+
+<!--
+managed beans used:
+ validateForm
+-->
+
+<f:view>
+
+ <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
+
+ <h:panelGroup id="body">
+
+ <h:messages showDetail="true" showSummary="false"/>
+
+ <h:form id="form1">
+ <h:panelGrid columns="3">
+
+ <h:outputLabel for="email" value="#{example_messages['email_comma']}" />
+ <h:inputText id="email" value="#{validateForm.email}" required="true">
+ <mcv:validateCSV subvalidatorId="org.apache.myfaces.commons.validator.Email" />
+ </h:inputText>
+ <h:message id="emailError" for="email" styleClass="error" />
+
+ <h:outputLabel for="creditCardNumber" value="#{example_messages['credit_dot']}" />
+ <h:inputText id="creditCardNumber" value="#{validateForm.creditCardNumber}" required="true">
+ <mcv:validateCSV subvalidatorId="org.apache.myfaces.commons.validator.CreditCard" separator="\\." />
+ </h:inputText>
+ <h:message id="creditCardNumberError" for="creditCardNumber" styleClass="error" />
+
+ <h:panelGroup/>
+ <h:commandButton id="validateButton" value="#{example_messages['button_submit']}" action="#{validateForm.submit}"/>
+ <h:panelGroup/>
+
+ </h:panelGrid>
+ </h:form>
+
+ </h:panelGroup>
+
+</f:view>
+
+<%@include file="inc/page_footer.jsp" %>
+
+</body>
+
+</html>
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCSV.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCSV.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCompareTo.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCompareTo.jsp?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCompareTo.jsp (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCompareTo.jsp Tue Jul 1 22:31:50 2008
@@ -0,0 +1,105 @@
+<%@ page session="false" contentType="text/html;charset=utf-8"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://myfaces.apache.org/commons/converters" prefix="mcc" %>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators" prefix="mcv" %>
+
+<html>
+
+<%@include file="inc/head.inc" %>
+
+<!--
+/*
+ * 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.
+ */
+//-->
+
+<body>
+
+<!--
+managed beans used:
+ validateForm
+-->
+
+<f:view>
+
+ <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
+
+ <h:panelGroup id="body">
+
+ <h:form id="form1">
+ <h:messages showDetail="true" showSummary="false"/>
+
+ <h:panelGrid columns="3">
+
+ <h:outputLabel for="baseInput" value="#{example_messages['validate_base']}" />
+ <h:inputText id="baseInput" value="#{validateForm.equal}" required="true"/>
+ <h:message id="baseError" for="baseInput" styleClass="error" />
+
+ <h:outputLabel for="eqInput" value="#{example_messages['validate_equal']}" />
+ <h:inputText id="eqInput" required="true">
+ <mcv:validateCompareTo for="baseInput" operator="eq" />
+ </h:inputText>
+ <h:message id="eqError" for="eqInput" styleClass="error" />
+
+ <h:outputLabel for="neInput" value="#{example_messages['validate_notequal']}" />
+ <h:inputText id="neInput" required="true">
+ <mcv:validateCompareTo for="baseInput" operator="ne" />
+ </h:inputText>
+ <h:message id="neError" for="neInput" styleClass="error" />
+
+ <h:outputLabel for="gtInput" value="#{example_messages['validate_greaterthan']}" />
+ <h:inputText id="gtInput" required="true">
+ <mcv:validateCompareTo for="baseInput" operator="gt" />
+ </h:inputText>
+ <h:message id="gtError" for="gtInput" styleClass="error" />
+
+ <h:outputLabel for="geInput" value="#{example_messages['validate_greaterthanequal']}" />
+ <h:inputText id="geInput" required="true">
+ <mcv:validateCompareTo for="baseInput" operator="ge" />
+ </h:inputText>
+ <h:message id="geError" for="geInput" styleClass="error" />
+
+ <h:outputLabel for="ltInput" value="#{example_messages['validate_lessthan']}" />
+ <h:inputText id="ltInput" required="true">
+ <mcv:validateCompareTo for="baseInput" operator="lt" />
+ </h:inputText>
+ <h:message id="ltError" for="ltInput" styleClass="error" />
+
+ <h:outputLabel for="leInput" value="#{example_messages['validate_lessthanequal']}" />
+ <h:inputText id="leInput" required="true">
+ <mcv:validateCompareTo for="baseInput" operator="le" />
+ </h:inputText>
+ <h:message id="leError" for="leInput" styleClass="error" />
+
+ <h:panelGroup/>
+ <h:commandButton id="validateButton" value="#{example_messages['button_submit']}" action="#{validateForm.submit}"/>
+ <h:panelGroup/>
+
+ </h:panelGrid>
+ </h:form>
+
+ </h:panelGroup>
+
+</f:view>
+
+<%@include file="inc/page_footer.jsp" %>
+
+</body>
+
+</html>
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCompareTo.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateCompareTo.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateUrl.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateUrl.jsp?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateUrl.jsp (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateUrl.jsp Tue Jul 1 22:31:50 2008
@@ -0,0 +1,69 @@
+<%@ page session="false" contentType="text/html;charset=utf-8"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://myfaces.apache.org/commons/converters" prefix="mcc" %>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators" prefix="mcv" %>
+
+<html>
+
+<%@include file="inc/head.inc" %>
+
+<!--
+/*
+ * 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.
+ */
+//-->
+
+<body>
+
+<!--
+managed beans used:
+ validateForm
+-->
+
+<f:view>
+
+ <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
+
+ <h:panelGroup id="body">
+
+ <h:form id="form1">
+ <h:panelGrid columns="3">
+
+ <h:outputLabel for="url" value="#{example_messages['validate_url']}" />
+ <h:inputText id="url" value="#{validateForm.url}" required="true">
+ <mcv:validateUrl schemes="http,https" allow2Slashes="true"/>
+ </h:inputText>
+ <h:message id="urlError" for="url" styleClass="error" />
+
+ <h:panelGroup/>
+ <h:commandButton id="validateButton" value="#{example_messages['button_submit']}" action="#{validateForm.submit}"/>
+ <h:panelGroup/>
+
+ </h:panelGrid>
+ </h:form>
+
+ </h:panelGroup>
+
+</f:view>
+
+<%@include file="inc/page_footer.jsp" %>
+
+</body>
+
+</html>
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateUrl.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-examples/src/main/webapp/validateUrl.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-utils/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 1 22:31:50 2008
@@ -0,0 +1,10 @@
+target
+.classpath
+.project
+.wtpmodules
+*.ipr
+*.iml
+*.iws
+.settings
+maven-eclipse.xml
+.externalToolsBuilder
Modified: myfaces/commons/branches/jsf_11/myfaces-commons-utils/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-utils/pom.xml?rev=673285&r1=673284&r2=673285&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-utils/pom.xml (original)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-utils/pom.xml Tue Jul 1 22:31:50 2008
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.myfaces.commons</groupId>
<artifactId>commons</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
</parent>
<artifactId>myfaces-commons-utils</artifactId>
<packaging>jar</packaging>
@@ -28,6 +28,10 @@
<dependencies>
<dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
</dependency>
@@ -40,4 +44,4 @@
<artifactId>junit</artifactId>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Added: myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ClassUtils.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ClassUtils.java?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ClassUtils.java (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ClassUtils.java Tue Jul 1 22:31:50 2008
@@ -0,0 +1,352 @@
+/*
+ * 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.commons.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import java.io.InputStream;
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.util.*;
+
+
+/**
+ * @author Manfred Geiler (latest modification by $Author$)
+ * @author Anton Koinov
+ * @version $Revision$ $Date$
+ */
+public final class ClassUtils
+{
+ //~ Static fields/initializers -----------------------------------------------------------------
+
+ private static final Log log = LogFactory.getLog(ClassUtils.class);
+
+ public static final Class BOOLEAN_ARRAY_CLASS = boolean[].class;
+ public static final Class BYTE_ARRAY_CLASS = byte[].class;
+ public static final Class CHAR_ARRAY_CLASS = char[].class;
+ public static final Class SHORT_ARRAY_CLASS = short[].class;
+ public static final Class INT_ARRAY_CLASS = int[].class;
+ public static final Class LONG_ARRAY_CLASS = long[].class;
+ public static final Class FLOAT_ARRAY_CLASS = float[].class;
+ public static final Class DOUBLE_ARRAY_CLASS = double[].class;
+ public static final Class OBJECT_ARRAY_CLASS = Object[].class;
+ public static final Class BOOLEAN_OBJECT_ARRAY_CLASS = Boolean[].class;
+ public static final Class BYTE_OBJECT_ARRAY_CLASS = Byte[].class;
+ public static final Class CHARACTER_OBJECT_ARRAY_CLASS = Character[].class;
+ public static final Class SHORT_OBJECT_ARRAY_CLASS = Short[].class;
+ public static final Class INTEGER_OBJECT_ARRAY_CLASS = Integer[].class;
+ public static final Class LONG_OBJECT_ARRAY_CLASS = Long[].class;
+ public static final Class FLOAT_OBJECT_ARRAY_CLASS = Float[].class;
+ public static final Class DOUBLE_OBJECT_ARRAY_CLASS = Double[].class;
+ public static final Class STRING_OBJECT_ARRAY_CLASS = String[].class;
+
+ public static final Map COMMON_TYPES = new HashMap(64);
+ static
+ {
+ COMMON_TYPES.put("byte", Byte.TYPE);
+ COMMON_TYPES.put("char", Character.TYPE);
+ COMMON_TYPES.put("double", Double.TYPE);
+ COMMON_TYPES.put("float", Float.TYPE);
+ COMMON_TYPES.put("int", Integer.TYPE);
+ COMMON_TYPES.put("long", Long.TYPE);
+ COMMON_TYPES.put("short", Short.TYPE);
+ COMMON_TYPES.put("boolean", Boolean.TYPE);
+ COMMON_TYPES.put("void", Void.TYPE);
+ COMMON_TYPES.put("java.lang.Object", Object.class);
+ COMMON_TYPES.put("java.lang.Boolean", Boolean.class);
+ COMMON_TYPES.put("java.lang.Byte", Byte.class);
+ COMMON_TYPES.put("java.lang.Character", Character.class);
+ COMMON_TYPES.put("java.lang.Short", Short.class);
+ COMMON_TYPES.put("java.lang.Integer", Integer.class);
+ COMMON_TYPES.put("java.lang.Long", Long.class);
+ COMMON_TYPES.put("java.lang.Float", Float.class);
+ COMMON_TYPES.put("java.lang.Double", Double.class);
+ COMMON_TYPES.put("java.lang.String", String.class);
+
+ COMMON_TYPES.put("byte[]", BYTE_ARRAY_CLASS);
+ COMMON_TYPES.put("char[]", CHAR_ARRAY_CLASS);
+ COMMON_TYPES.put("double[]", DOUBLE_ARRAY_CLASS);
+ COMMON_TYPES.put("float[]", FLOAT_ARRAY_CLASS);
+ COMMON_TYPES.put("int[]", INT_ARRAY_CLASS);
+ COMMON_TYPES.put("long[]", LONG_ARRAY_CLASS);
+ COMMON_TYPES.put("short[]", SHORT_ARRAY_CLASS);
+ COMMON_TYPES.put("boolean[]", BOOLEAN_ARRAY_CLASS);
+ COMMON_TYPES.put("java.lang.Object[]", OBJECT_ARRAY_CLASS);
+ COMMON_TYPES.put("java.lang.Boolean[]", BOOLEAN_OBJECT_ARRAY_CLASS);
+ COMMON_TYPES.put("java.lang.Byte[]", BYTE_OBJECT_ARRAY_CLASS);
+ COMMON_TYPES.put("java.lang.Character[]", CHARACTER_OBJECT_ARRAY_CLASS);
+ COMMON_TYPES.put("java.lang.Short[]", SHORT_OBJECT_ARRAY_CLASS);
+ COMMON_TYPES.put("java.lang.Integer[]", INTEGER_OBJECT_ARRAY_CLASS);
+ COMMON_TYPES.put("java.lang.Long[]", LONG_OBJECT_ARRAY_CLASS);
+ COMMON_TYPES.put("java.lang.Float[]", FLOAT_OBJECT_ARRAY_CLASS);
+ COMMON_TYPES.put("java.lang.Double[]", DOUBLE_OBJECT_ARRAY_CLASS);
+ COMMON_TYPES.put("java.lang.String[]", STRING_OBJECT_ARRAY_CLASS);
+ // array of void is not a valid type
+ }
+
+ /** utility class, do not instantiate */
+ private ClassUtils()
+ {
+ // utility class, disable instantiation
+ }
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ /**
+ * Tries a Class.loadClass with the context class loader of the current thread first and
+ * automatically falls back to the ClassUtils class loader (i.e. the loader of the
+ * myfaces.jar lib) if necessary.
+ *
+ * @param type fully qualified name of a non-primitive non-array class
+ * @return the corresponding Class
+ * @throws NullPointerException if type is null
+ * @throws ClassNotFoundException
+ */
+ public static Class classForName(String type)
+ throws ClassNotFoundException
+ {
+ if (type == null) throw new NullPointerException("type");
+ try
+ {
+ // Try WebApp ClassLoader first
+ return Class.forName(type,
+ false, // do not initialize for faster startup
+ Thread.currentThread().getContextClassLoader());
+ }
+ catch (ClassNotFoundException ignore)
+ {
+ // fallback: Try ClassLoader for ClassUtils (i.e. the myfaces.jar lib)
+ return Class.forName(type,
+ false, // do not initialize for faster startup
+ ClassUtils.class.getClassLoader());
+ }
+ }
+
+
+ /**
+ * Same as {@link #classForName(String)}, but throws a RuntimeException
+ * (FacesException) instead of a ClassNotFoundException.
+ *
+ * @return the corresponding Class
+ * @throws NullPointerException if type is null
+ * @throws FacesException if class not found
+ */
+ public static Class simpleClassForName(String type)
+ {
+ try
+ {
+ return classForName(type);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.error("Class " + type + " not found", e);
+ throw new FacesException(e);
+ }
+ }
+
+
+ /**
+ * Similar as {@link #classForName(String)}, but also supports primitive types
+ * and arrays as specified for the JavaType element in the JavaServer Faces Config DTD.
+ *
+ * @param type fully qualified class name or name of a primitive type, both optionally
+ * followed by "[]" to indicate an array type
+ * @return the corresponding Class
+ * @throws NullPointerException if type is null
+ * @throws ClassNotFoundException
+ */
+ public static Class javaTypeToClass(String type)
+ throws ClassNotFoundException
+ {
+ if (type == null) throw new NullPointerException("type");
+
+ // try common types and arrays of common types first
+ Class clazz = (Class) COMMON_TYPES.get(type);
+ if (clazz != null)
+ {
+ return clazz;
+ }
+
+ int len = type.length();
+ if (len > 2 && type.charAt(len - 1) == ']' && type.charAt(len - 2) == '[')
+ {
+ String componentType = type.substring(0, len - 2);
+ Class componentTypeClass = classForName(componentType);
+ return Array.newInstance(componentTypeClass, 0).getClass();
+ }
+
+ return classForName(type);
+
+ }
+
+
+ /**
+ * Same as {@link #javaTypeToClass(String)}, but throws a RuntimeException
+ * (FacesException) instead of a ClassNotFoundException.
+ *
+ * @return the corresponding Class
+ * @throws NullPointerException if type is null
+ * @throws FacesException if class not found
+ */
+ public static Class simpleJavaTypeToClass(String type)
+ {
+ try
+ {
+ return javaTypeToClass(type);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.error("Class " + type + " not found", e);
+ throw new FacesException(e);
+ }
+ }
+
+ public static InputStream getResourceAsStream(String resource)
+ {
+ InputStream stream = Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream(resource);
+ if (stream == null)
+ {
+ // fallback
+ stream = ClassUtils.class.getClassLoader().getResourceAsStream(resource);
+ }
+ return stream;
+ }
+
+ /**
+ * @param resource Name of resource(s) to find in classpath
+ * @param defaultObject The default object to use to determine the class loader (if none associated with current thread.)
+ * @return Iterator over URL Objects
+ */
+ public static Iterator getResources(String resource, Object defaultObject)
+ {
+ try
+ {
+ Enumeration resources = getCurrentLoader(defaultObject).getResources(resource);
+ List lst = new ArrayList();
+ while (resources.hasMoreElements())
+ {
+ lst.add(resources.nextElement());
+ }
+ return lst.iterator();
+ }
+ catch (IOException e)
+ {
+ log.error(e.getMessage(), e);
+ throw new FacesException(e);
+ }
+ }
+
+
+ public static Object newInstance(String type)
+ throws FacesException
+ {
+ if (type == null) return null;
+ return newInstance(simpleClassForName(type));
+ }
+
+ public static Object newInstance(String type, Class expectedType) throws FacesException
+ {
+ return newInstance(type, expectedType == null ? null : new Class[] {expectedType});
+ }
+
+ public static Object newInstance(String type, Class[] expectedTypes)
+ {
+ if (type == null)
+ return null;
+
+ Class clazzForName = simpleClassForName(type);
+
+ if(expectedTypes != null)
+ {
+ for (int i = 0, size = expectedTypes.length; i < size; i++)
+ {
+ if (!expectedTypes[i].isAssignableFrom(clazzForName))
+ {
+ throw new FacesException("'" + type + "' does not implement expected type '" + expectedTypes[i]
+ + "'");
+ }
+ }
+ }
+
+ return newInstance(clazzForName);
+ }
+
+ public static Object newInstance(Class clazz)
+ throws FacesException
+ {
+ try
+ {
+ return clazz.newInstance();
+ }
+ catch(NoClassDefFoundError e)
+ {
+ log.error("Class : "+clazz.getName()+" not found.",e);
+ throw new FacesException(e);
+ }
+ catch (InstantiationException e)
+ {
+ log.error(e.getMessage(), e);
+ throw new FacesException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ log.error(e.getMessage(), e);
+ throw new FacesException(e);
+ }
+ }
+ /*
+ public static Object convertToType(Object value, Class desiredClass)
+ {
+ if (value == null) return null;
+
+ try
+ {
+ ExpressionFactory expFactory = FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
+ return expFactory.coerceToType(value, desiredClass);
+ }
+ catch (Exception e)
+ {
+ String message = "Cannot coerce " + value.getClass().getName()
+ + " to " + desiredClass.getName();
+ log.error(message, e);
+ throw new FacesException(message, e);
+ }
+ }*/
+
+ /**
+ * Gets the ClassLoader associated with the current thread. Returns the class loader associated with
+ * the specified default object if no context loader is associated with the current thread.
+ *
+ * @param defaultObject The default object to use to determine the class loader (if none associated with current thread.)
+ * @return ClassLoader
+ */
+ protected static ClassLoader getCurrentLoader(Object defaultObject)
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if(loader == null)
+ {
+ loader = defaultObject.getClass().getClassLoader();
+ }
+ return loader;
+ }
+}
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ClassUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/ClassUtils.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java?rev=673285&r1=673284&r2=673285&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java (original)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java Tue Jul 1 22:31:50 2008
@@ -56,8 +56,8 @@
// nope
}
- /** Default bundle for messages (<code>javax.faces.Messages</code>) */
- private static final String DEFAULT_BUNDLE = "javax.faces.Messages";
+ /** Default bundle for messages (<code>org.apache.myfaces.commons.Messages</code>) */
+ private static final String DEFAULT_BUNDLE = "org.apache.myfaces.commons.Messages";//javax.faces.Messages
/** Suffix for message details (<code>_detail</code>)*/
private static final String DETAIL_SUFFIX = "_detail";
Added: myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/resources/org/apache/myfaces/commons/Messages.properties
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/resources/org/apache/myfaces/commons/Messages.properties?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/resources/org/apache/myfaces/commons/Messages.properties (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/resources/org/apache/myfaces/commons/Messages.properties Tue Jul 1 22:31:50 2008
@@ -0,0 +1,33 @@
+# Copyright 2004 The Apache Software Foundation.
+#
+# Licensed 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.
+
+org.apache.myfaces.commons.validator.Email.INVALID=Validation Error
+org.apache.myfaces.commons.validator.Email.INVALID_detail=The given value ({0}) is not a correct email-address.
+org.apache.myfaces.commons.validator.Equal.INVALID=Validation Error
+org.apache.myfaces.commons.validator.Equal.INVALID_detail=The given value ({0}) is not equal with value of "{1}".
+org.apache.myfaces.commons.validator.Creditcard.INVALID=Validation Error
+org.apache.myfaces.commons.validator.Creditcard.INVALID_detail=The given value ({0}) is not a correct creditcard
+org.apache.myfaces.commons.validator.Regexpr.INVALID=Validation Error
+org.apache.myfaces.commons.validator.Regexpr.INVALID_detail=The given value ({0}) is not valid.
+org.apache.myfaces.commons.validator.DateRestrictionValidator.DAY=Date is not allowed.
+org.apache.myfaces.commons.validator.DateRestrictionValidator.DAY_detail=The date you entered is not allowed.
+org.apache.myfaces.commons.validator.DateRestrictionValidator.MONTH=Invalid Month
+org.apache.myfaces.commons.validator.DateRestrictionValidator.MONTH_detail=Enter a date from the following month(s): {0}.
+org.apache.myfaces.commons.validator.DateRestrictionValidator.WEEKDAY=Invalid Weekday
+org.apache.myfaces.commons.validator.DateRestrictionValidator.WEEKDAY_detail=Enter a date from the following weekday(s)\: {0}.
+org.apache.myfaces.commons.validator.csv.NOT_STRING=The value {0} is not a String
+org.apache.myfaces.commons.validator.csv.SUFFIX= - on entry #{0}
+org.apache.myfaces.commons.validator.csv.INVALID_SEPARATOR=invalid separator {0}
+org.apache.myfaces.commons.validator.Url.INVALID = The given url {0} is invalid
+org.apache.myfaces.commons.validator.ISBN.INVALID = The given isbn {0} is invalid
\ No newline at end of file
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/resources/org/apache/myfaces/commons/Messages.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-utils/src/main/resources/org/apache/myfaces/commons/Messages.properties
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-validators/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 1 22:31:50 2008
@@ -0,0 +1,10 @@
+target
+.classpath
+.project
+.wtpmodules
+*.ipr
+*.iml
+*.iws
+.settings
+maven-eclipse.xml
+.externalToolsBuilder
Modified: myfaces/commons/branches/jsf_11/myfaces-commons-validators/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-validators/pom.xml?rev=673285&r1=673284&r2=673285&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-validators/pom.xml (original)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-validators/pom.xml Tue Jul 1 22:31:50 2008
@@ -20,27 +20,99 @@
<parent>
<groupId>org.apache.myfaces.commons</groupId>
<artifactId>commons</artifactId>
- <version>0.0.1-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
</parent>
<artifactId>myfaces-validators</artifactId>
<packaging>jar</packaging>
<name>Apache MyFaces Commons Validators</name>
- <build>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <excludes>
+ <exclude>**/*.vm</exclude>
+ </excludes>
+ </resource>
+ </resources>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <inherited>true</inherited>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
+ <groupId>org.apache.myfaces.buildtools</groupId>
+ <artifactId>myfaces-builder-plugin</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build-metadata</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>makefacesconfig</id>
+ <configuration>
+ <templateFile>faces-config11.vm</templateFile>
+ <xmlFile>META-INF/faces-config.xml</xmlFile>
+ </configuration>
+ <goals>
+ <goal>make-config</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>makeval</id>
+ <goals>
+ <goal>make-validators</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>make_validator_tags</id>
+ <goals>
+ <goal>make-validator-tags</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>makemcctld</id>
+ <configuration>
+ <xmlFile>META-INF/mcc.tld</xmlFile>
+ <xmlBaseFile>src/main/conf/META-INF/mcc-base.tld</xmlBaseFile>
+ <templateFile>tomahawk.vm</templateFile>
+ <params>
+ <shortname>mcv</shortname>
+ <uri>http://myfaces.apache.org/commons/validators</uri>
+ <displayname>Myfaces Commons Validator Tag Library 1.1.</displayname>
+ <description> MyFaces subproject that contains validator to be used with any JSF 1.1 implementation.</description>
+ </params>
+ <modelIds>
+ <modelId>myfaces-validators</modelId>
+ </modelIds>
+ </configuration>
+ <goals>
+ <goal>make-config</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>makemcctaglib</id>
+ <configuration>
+ <xmlFile>META-INF/mcc.taglib.xml</xmlFile>
+ <xmlBaseFile>src/main/conf/META-INF/facelets-taglib-base.xml</xmlBaseFile>
+ <templateFile>facelets-taglib.vm</templateFile>
+ <params>
+ <shortname>mcv</shortname>
+ <uri>http://myfaces.apache.org/commons/validators</uri>
+ </params>
+ <modelIds>
+ <modelId>myfaces-validators</modelId>
+ </modelIds>
+ </configuration>
+ <goals>
+ <goal>make-config</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
+ <!--
<plugin>
- <groupId>org.apache.myfaces.trinidadbuild</groupId>
- <artifactId>maven-faces-plugin</artifactId>
- <version>1.2.6-SNAPSHOT</version>
+ <groupId>org.apache.myfaces.buildtools</groupId>
+ <artifactId>myfaces-faces-plugin</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
<configuration>
<taglibs>
<mcv>http://myfaces.apache.org/commons/validators</mcv>
@@ -99,6 +171,7 @@
</execution>
</executions>
</plugin>
+ -->
</plugins>
</build>
@@ -120,7 +193,13 @@
<artifactId>commons-validator</artifactId>
<version>1.3.1</version>
<scope>compile</scope>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>oro</groupId>
+ <artifactId>oro</artifactId>
+ <version>2.0.8</version>
+ <scope>compile</scope>
+ </dependency>
<dependency>
<groupId>org.apache.myfaces.commons</groupId>
<artifactId>myfaces-commons-utils</artifactId>
@@ -130,5 +209,69 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.shale</groupId>
+ <artifactId>shale-test</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.myfaces</groupId>
+ <artifactId>myfaces-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.myfaces</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>myfaces</groupId>
+ <artifactId>myfaces-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>myfaces</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>cactus</groupId>
+ <artifactId>cactus</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jmock</groupId>
+ <artifactId>jmock</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jmock</groupId>
+ <artifactId>jmock-cglib</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Added: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCSVValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCSVValidator.java?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCSVValidator.java (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCSVValidator.java Tue Jul 1 22:31:50 2008
@@ -0,0 +1,161 @@
+/*
+ * 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.commons.validator;
+
+import java.util.regex.PatternSyntaxException;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.myfaces.commons.util.MessageUtils;
+
+/**
+ * Validation by validating comma separated values individually.
+ *
+ * @JSFValidator
+ * name = "mcv:validateCSV"
+ * class = "org.apache.myfaces.commons.validator.CSVValidator"
+ * tagClass = "org.apache.myfaces.commons.validator.ValidateCSVTag"
+ * serialuidtag = "-8874279182242196266L"
+ *
+ * @author Lance Frohman
+ *
+ * @version $Revision$ $Date$
+ */
+public abstract class AbstractCSVValidator extends ValidatorBase {
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.csv";
+ /**
+ * <p>The message identifiers of the {@link FacesMessage} to be created if
+ * the check fails.</p>
+ */
+ public static final String CSV_NOT_STRING_MESSAGE_ID = "org.apache.myfaces.commons.validator.csv.NOT_STRING";
+ public static final String CSV_INVALID_SEPARATOR_MESSAGE_ID = "org.apache.myfaces.commons.validator.csv.INVALID_SEPARATOR";
+ public static final String CSV_SUFFIX_MESSAGE_ID = "org.apache.myfaces.commons.validator.csv.SUFFIX";
+ private static final String DEFAULT_SEPARATOR = ",";
+
+ /**
+ * @JSFProperty
+ * @return the VALIDATOR_ID of the actual validator to be used
+ */
+ public abstract String getSubvalidatorId();
+
+ /**
+ * @param the VALIDATOR_ID of the actual validator to be used
+ */
+ public abstract void setSubvalidatorId(String subvalidatorId);
+
+ /**
+ * @JSFProperty
+ * literalOnly = "true"
+ * @return the separator character to separate values
+ */
+ public abstract String getSeparator();
+
+ /**
+ * @param the separator character to separate values
+ */
+ public abstract void setSeparator(String separator);
+
+ private FacesMessage addMessage(FacesMessage oldMsg, FacesMessage newMsg, int index, String suffixMessageKey) {
+ if (oldMsg != null && newMsg.getSeverity().getOrdinal() < oldMsg.getSeverity().getOrdinal())
+ return oldMsg;
+ String summaryMessageText = null;
+ String detailMessageText = null;
+ if (oldMsg == null || newMsg.getSeverity().getOrdinal() > oldMsg.getSeverity().getOrdinal()) {
+ summaryMessageText = null;
+ detailMessageText = null;
+ }
+ else {
+ summaryMessageText = oldMsg.getSummary();
+ detailMessageText = oldMsg.getDetail();
+ }
+ Object[] args = { new Integer(index + 1) };
+ FacesMessage suffixMessage = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, suffixMessageKey, args);
+ String summarySuffix = suffixMessage.getSummary();
+ String detailSuffix = suffixMessage.getDetail();
+ if (summarySuffix == null)
+ summarySuffix = detailSuffix;
+ else if (detailSuffix == null)
+ detailSuffix = summarySuffix;
+ String summary = newMsg.getSummary();
+ if (summaryMessageText == null)
+ summaryMessageText = summary + summarySuffix;
+ else
+ summaryMessageText += ", " + summary + summarySuffix;
+ String detail = newMsg.getDetail();
+ if (detailMessageText == null)
+ detailMessageText = detail + detailSuffix;
+ else
+ detailMessageText += ", " + detail + detailSuffix;
+ return new FacesMessage(newMsg.getSeverity(), summaryMessageText, detailMessageText);
+ }
+
+ 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");
+
+ if (value == null)
+ {
+ return;
+ }
+
+ String suffixMessageKey = getMessage();
+ if (suffixMessageKey == null)
+ suffixMessageKey = CSV_SUFFIX_MESSAGE_ID;
+ FacesMessage facesMsg = null;
+ // value must be a String
+ if (!(value instanceof String)) {
+ Object[] args = { value };
+ throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, CSV_NOT_STRING_MESSAGE_ID, args));
+ }
+ Validator validator = facesContext.getApplication().createValidator(getSubvalidatorId());
+ if (getSeparator() == null)
+ setSeparator(DEFAULT_SEPARATOR);
+ String[] values = null;
+ try {
+ values = ((String)value).split(getSeparator());
+ }
+ catch (PatternSyntaxException e) {
+ Object[] args = { getSeparator() };
+ throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, CSV_INVALID_SEPARATOR_MESSAGE_ID, args));
+ }
+
+ // loop through the separated values and validate each one
+ for (int i = 0; i < values.length; i++) {
+ if (values[i].trim().length() == 0) {
+ continue;
+ }
+ else try {
+ validator.validate(facesContext, uiComponent, values[i]);
+ }
+ catch (ValidatorException e) {
+ facesMsg = addMessage(facesMsg, e.getFacesMessage(), i, suffixMessageKey);
+ }
+ }
+ if (facesMsg != null)
+ throw new ValidatorException(facesMsg);
+ }
+}
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCSVValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCSVValidator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java Tue Jul 1 22:31:50 2008
@@ -0,0 +1,495 @@
+/*
+ * 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.commons.validator;
+
+import java.util.Comparator;
+
+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.el.ValueBinding;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.Renderer;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.myfaces.commons.util.MessageUtils;
+
+/**
+ *
+ * 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.commons.validator.CompareTo</validator-id>
+ * <validator-class>org.apache.myfaces.commons.validator.CompareToValidator</validator-class>
+ * </validator>
+ *
+ *
+ * Facelets configuration (inside a taglib.xml file):
+ *
+ * <tag>
+ * <tag-name>compareToValidator</tag-name>
+ * <validator>
+ * <validator-id>org.apache.myfaces.commons.validator.CompareTo</validator-id>
+ * </validator>
+ * </tag>
+ *
+ *
+ * Example usage:
+ *
+ * <t:inputCalendar id="startDate"/>
+ * <t:inputCalendar id="endDate">
+ * <mcv:compareToValidator operator="gt" for="startDate" />
+ * <mcv:compareToValidator operator="gt" for="startDate" message="Start date must be before end date." />
+ * <mcv:compareToValidator operator="gt" for="startDate" message="{0} must be {2} {3}" />
+ * <mcv:compareToValidator operator="gt" for="startDate" alternateOperatorName="after" />
+ * <mcv:compareToValidator operator="gt" for="startDate" message="{0} must be {2} {3}" alternateOperatorName="after" />
+ * <mcv: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 = "mcv:validateCompareTo"
+ * class = "org.apache.myfaces.commons.validator.CompareToValidator"
+ * tagClass = "org.apache.myfaces.commons.validator.ValidateCompareToTag"
+ * serialuidtag = "-8879289182242196266L"
+ *
+ * @author Mike Kienenberger (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public abstract class AbstractCompareToValidator extends ValidatorBase {
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.commons.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 AbstractCompareToValidator(){
+ super();
+ }
+
+ 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
+ {
+ try
+ {
+ foreignValue = getConvertedValueNonValid(facesContext, foreignComponent);
+ }
+ catch(ConverterException e)
+ {
+ /*
+ * If the value cannot be converted this should return,
+ * because does not have sense compare one
+ * foreign invalid value with other value.
+ * this force end the validation but do not continue
+ * with the next phases, because the converter
+ * of the foreign component fails and show a validation error.
+ */
+ return;
+ }
+ }
+
+ // 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 abstract String getFor();
+
+ /**
+ * @param string the foreign component_id, on which a value should be validated
+ */
+ public abstract void setFor(String 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 abstract String getOperator();
+
+ public abstract void setOperator(String operator);
+
+ /**
+ * Value binding for an alternate java.util.Comparator object if component
+ * values don't implement Comparable
+ *
+ * @JSFProperty
+ * @return
+ */
+ public abstract Object getComparator();
+
+ public abstract void setComparator(Object comparator);
+
+ /**
+ * custom operator name in error message (ie "after" instead of "greater than" for dates)
+ *
+ * @JSFProperty
+ * @return
+ */
+ public abstract String getAlternateOperatorName();
+
+ public abstract void setAlternateOperatorName(String alternateOperatorName);
+
+ // ---------------- 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
+ ValueBinding vb = component.getValueBinding("value");
+ if (vb == null) return null;
+
+ Class valueType = vb.getType(facesContext);
+ 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)
+ throws ConverterException
+ {
+ Object componentValueObject;
+ Object submittedValue = ((EditableValueHolder) component).getSubmittedValue();
+ if (submittedValue == null)
+ {
+ componentValueObject = null;
+ }
+ else
+ {
+ 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);
+ }
+ else
+ {
+ componentValueObject = submittedValue;
+ }
+ }else{
+ componentValueObject = submittedValue;
+ }
+ }
+ return componentValueObject;
+ }
+}
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCreditCardValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCreditCardValidator.java?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCreditCardValidator.java (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCreditCardValidator.java Tue Jul 1 22:31:50 2008
@@ -0,0 +1,175 @@
+/*
+ * 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.commons.validator;
+
+import org.apache.myfaces.commons.validator.ValidatorBase;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.ValidatorException;
+
+/**
+ * A custom validator for creditCards, based upon Jakarta Commons.
+ *
+ * Unless otherwise specified, all attributes accept static values or EL expressions
+ *
+ * @JSFValidator
+ * name = "mcv:validateCreditCard"
+ * class = "org.apache.myfaces.commons.validator.CreditCardValidator"
+ * bodyContent = "empty"
+ * tagClass = "org.apache.myfaces.commons.validator.ValidateCreditCardTag"
+ * serialuidtag = "3810660506302799072L"
+ *
+ * @author mwessendorf (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public abstract class AbstractCreditCardValidator extends ValidatorBase {
+
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.CreditCard";
+
+ /**
+ * <p>The message identifier of the {@link FacesMessage} to be created if
+ * the creditcard check fails.</p>
+ */
+ public static final String CREDITCARD_MESSAGE_ID = "org.apache.myfaces.commons.validator.Creditcard.INVALID";
+
+ public AbstractCreditCardValidator(){
+ }
+
+ //Field, to init the desired Validator
+ private int _initSum = 0;
+
+ private org.apache.commons.validator.CreditCardValidator creditCardValidator = null;
+
+ /**
+ *
+ */
+ 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");
+
+ if (value == null)
+ {
+ return;
+ }
+ initValidator();
+ if (!this.creditCardValidator.isValid(value.toString())){
+ Object[] args = {value.toString()};
+ throw new ValidatorException(getFacesMessage(CREDITCARD_MESSAGE_ID, args));
+ }
+ }
+
+
+ // -------------------------------------------------------- Private Methods
+
+ /**
+ * <p>initializes the desired validator.</p>
+ */
+
+ private void initValidator() {
+ if(isNone()){
+ //no cardtypes are allowed
+ creditCardValidator = new org.apache.commons.validator.CreditCardValidator(org.apache.commons.validator.CreditCardValidator.NONE);
+ }
+ else{
+ computeValidators();
+ creditCardValidator = new org.apache.commons.validator.CreditCardValidator(_initSum);
+ }
+ }
+
+ /**
+ * private methode, that counts the desired creditCards
+ */
+ private void computeValidators(){
+ if(isAmex()){
+ this._initSum= org.apache.commons.validator.CreditCardValidator.AMEX + _initSum;
+ }
+ if(isVisa()){
+ this._initSum= org.apache.commons.validator.CreditCardValidator.VISA+ _initSum;
+ }
+ if(isMastercard()){
+ this._initSum= org.apache.commons.validator.CreditCardValidator.MASTERCARD+ _initSum;
+ }
+ if(isDiscover()){
+ this._initSum= org.apache.commons.validator.CreditCardValidator.DISCOVER+ _initSum;
+ }
+ }
+
+ //GETTER & SETTER
+
+ /**
+ * american express cards
+ *
+ * @JSFProperty
+ * defaultValue = "true"
+ */
+ public abstract boolean isAmex();
+
+ /**
+ * validation for discover
+ *
+ * @JSFProperty
+ * defaultValue = "true"
+ */
+ public abstract boolean isDiscover();
+
+ /**
+ * validation for mastercard
+ *
+ * @JSFProperty
+ * defaultValue = "true"
+ */
+ public abstract boolean isMastercard();
+
+ /**
+ * none of the given cardtypes is allowed.
+ *
+ * @JSFProperty
+ * defaultValue = "false"
+ */
+ public abstract boolean isNone();
+
+ /**
+ * validation for visa
+ *
+ * @JSFProperty
+ * defaultValue = "true"
+ */
+ public abstract boolean isVisa();
+
+ public abstract void setAmex(boolean b);
+
+ public abstract void setDiscover(boolean b);
+
+ public abstract void setMastercard(boolean b);
+
+ public abstract void setNone(boolean b);
+
+ public abstract void setVisa(boolean b);
+
+}
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCreditCardValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCreditCardValidator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java?rev=673285&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java (added)
+++ myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java Tue Jul 1 22:31:50 2008
@@ -0,0 +1,94 @@
+/*
+ * 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.commons.validator;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.commons.validator.GenericValidator;
+import org.apache.myfaces.commons.validator.ValidatorBase;
+
+/**
+ * A custom validator for reg. expr., based upons Jakarta Commons.
+ *
+ * Unless otherwise specified, all attributes accept static values or EL expressions.
+ *
+ * @JSFValidator
+ * name = "mcv:validateRegExpr"
+ * class = "org.apache.myfaces.commons.validator.RegExprValidator"
+ * tagClass = "org.apache.myfaces.commons.validator.ValidateRegExprTag"
+ * serialuidtag = "-449945949876262076L"
+ *
+ * @author mwessendorf (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public abstract class AbstractRegExprValidator extends ValidatorBase {
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.commons.validator.RegExpr";
+
+ /**
+ * <p>The message identifier of the {@link FacesMessage} to be created if
+ * the regex check fails.</p>
+ */
+ public static final String REGEXPR_MESSAGE_ID = "org.apache.myfaces.commons.validator.RegExpr.INVALID";
+
+ public AbstractRegExprValidator(){
+ }
+
+ 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");
+
+ if (value == null)
+ {
+ return;
+ }
+ Object[] args = {value.toString()};
+ if(!GenericValidator.matchRegexp(value.toString(),"^"+getPattern()+"$")){
+ throw new ValidatorException(getFacesMessage(REGEXPR_MESSAGE_ID, args));
+ }
+ }
+
+ // -------------------------------------------------------- GETTER & SETTER
+
+ /**
+ * the pattern, which is the base of the validation
+ *
+ * @JSFProperty
+ * literalOnly = "true"
+ * @return the pattern, on which a value should be validated
+ */
+ public abstract String getPattern();
+
+ /**
+ * @param string the pattern, on which a value should be validated
+ */
+ public abstract void setPattern(String string);
+
+}
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/commons/branches/jsf_11/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL