You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2011/09/06 18:16:41 UTC
svn commit: r1165747 - in /myfaces/tobago/trunk/tobago-example:
tobago-example-demo/
tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/
tobago-example-demo/src/main/webapp/WEB-INF/
tobago-example-demo/src/main/webapp/content/06/0...
Author: lofwyr
Date: Tue Sep 6 16:16:41 2011
New Revision: 1165747
URL: http://svn.apache.org/viewvc?rev=1165747&view=rev
Log:
TOBAGO-1022: Support for a default validator in input components like JSF 2.0 (JSR-303)
- prepare the demo to use JSR-303
Added:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Jsr303Bean.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/06/01/
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/06/01/validation-jsr303.xhtml
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/pom.xml
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/web.xml
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/in/in.xhtml
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/pom.xml?rev=1165747&r1=1165746&r2=1165747&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/pom.xml Tue Sep 6 16:16:41 2011
@@ -134,6 +134,9 @@
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-jsf12</artifactId>
+<!-- for JSF 2.0 todo: make a profile
+ <artifactId>openwebbeans-jsf</artifactId>
+-->
<version>${openwebbeans.version}</version>
</dependency>
<dependency>
@@ -170,6 +173,9 @@
<dependency>
<groupId>org.apache.myfaces.extensions.cdi.modules</groupId>
<artifactId>myfaces-extcdi-jsf12-module-api</artifactId>
+<!-- for JSF 2.0 todo: make a profile
+ <artifactId>myfaces-extcdi-jsf20-module-api</artifactId>
+-->
<version>${myfaces-extcdi.version}</version>
<scope>compile</scope>
</dependency>
@@ -177,10 +183,22 @@
<dependency>
<groupId>org.apache.myfaces.extensions.cdi.modules</groupId>
<artifactId>myfaces-extcdi-jsf12-module-impl</artifactId>
+<!-- for JSF 2.0 todo: make a profile
+ <artifactId>myfaces-extcdi-jsf20-module-impl</artifactId>
+-->
<version>${myfaces-extcdi.version}</version>
<scope>runtime</scope>
</dependency>
+<!-- which repository
+ <dependency>
+ <groupId>org.apacheExtras.myfaces.codi.addon</groupId>
+ <artifactId>controlled-bootstrapping-addon</artifactId>
+ <version>1.0.0</version>
+ <scope>compile</scope>
+ </dependency>
+-->
+
<dependency>
<groupId>org.apache.myfaces.tobago</groupId>
<artifactId>tobago-example-data</artifactId>
@@ -293,6 +311,36 @@
<scope>compile</scope>
-->
</dependency>
+
+<!--
+ for JSF 2.0 and Bean Validation (JSR-303)
+ todo: make a profile
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>2.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.web</groupId>
+ <artifactId>el-impl</artifactId>
+ <version>2.2</version>
+ </dependency>
+-->
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-annotation_1.1_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.0.2.GA</version>
+ </dependency>
+
</dependencies>
<profiles>
<profile>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Jsr303Bean.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Jsr303Bean.java?rev=1165747&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Jsr303Bean.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Jsr303Bean.java Tue Sep 6 16:16:41 2011
@@ -0,0 +1,72 @@
+package org.apache.myfaces.tobago.example.demo;
+
+/*
+ * 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.
+ */
+
+import org.apache.myfaces.tobago.util.FacesVersion;
+import org.hibernate.validator.constraints.Length;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.RequestScoped;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.inject.Named;
+import javax.validation.constraints.NotNull;
+
+@RequestScoped
+@Named(value = "jsr303")
+public class Jsr303Bean {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Jsr303Bean.class);
+
+ @NotNull
+ private String required;
+
+ @Length(min = 5, max = 10)
+ private String length;
+
+ public String action() {
+ LOG.info("Action of JSR-303 called.");
+
+ final FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ if (! FacesVersion.supports20()) {
+ facesContext.addMessage(null,
+ new FacesMessage(
+ FacesMessage.SEVERITY_WARN, "Bean Validation not available with JSF version less than 2.0.", null));
+ }
+
+ return facesContext.getViewRoot().getViewId();
+ }
+
+ public String getRequired() {
+ return required;
+ }
+
+ public void setRequired(String required) {
+ this.required = required;
+ }
+
+ public String getLength() {
+ return length;
+ }
+
+ public void setLength(String length) {
+ this.length = length;
+ }
+}
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml?rev=1165747&r1=1165746&r2=1165747&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml Tue Sep 6 16:16:41 2011
@@ -69,6 +69,11 @@
<param-value>true</param-value>
</context-param>
+ <context-param>
+ <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
<filter>
<filter-name>multipartFormdataFilter</filter-name>
<filter-class>org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter</filter-class>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/06/01/validation-jsr303.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/06/01/validation-jsr303.xhtml?rev=1165747&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/06/01/validation-jsr303.xhtml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/06/01/validation-jsr303.xhtml Tue Sep 6 16:16:41 2011
@@ -0,0 +1,54 @@
+<?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.
+-->
+
+<ui:composition template="/WEB-INF/tags/layout/overview.xhtml"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:tx="http://myfaces.apache.org/tobago/extension"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core">
+ <ui:param name="title" value="JSR-303: Bean Validation"/>
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout rows="40px;fixed;fixed;*;fixed"/>
+ </f:facet>
+
+ <tc:out value="TODO: JSR-303 Bean Validation - This example page only validates with JSF-2.0 or later."/>
+
+ <tc:messages/>
+
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout rows="auto;auto;auto;auto"/>
+ </f:facet>
+ <tx:in label="Required" value="#{jsr303.required}"/>
+ <tx:in label="Length" value="#{jsr303.length}"/>
+ </tc:panel>
+
+ <tc:cell/>
+
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout columns="1*;100px"/>
+ </f:facet>
+ <tc:cell/>
+ <tc:button action="#{jsr303.action}" label="#{overviewBundle.validation_submit}"/>
+ </tc:panel>
+
+ </tc:panel>
+</ui:composition>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/web.xml?rev=1165747&r1=1165746&r2=1165747&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/WEB-INF/web.xml Tue Sep 6 16:16:41 2011
@@ -45,6 +45,16 @@
<param-value>*.xhtml</param-value>
</context-param>
+ <context-param>
+ <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/in/in.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/in/in.xhtml?rev=1165747&r1=1165746&r2=1165747&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/in/in.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/webapp/tc/in/in.xhtml Tue Sep 6 16:16:41 2011
@@ -24,10 +24,12 @@
<tc:page>
<f:facet name="layout">
- <tc:gridLayout rows="auto;auto;auto;*"/>
+ <tc:gridLayout rows="auto;auto;auto;auto;*"/>
</f:facet>
<tc:gridLayoutConstraint width="600px" height="300px"/>
+ <tc:messages/>
+
<tx:in label="First Value" labelWidth="250px" value="#{in.first}"/>
<tx:in label="Second Value (Required)" labelWidth="250px" value="#{in.second}" required="true"/>