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 2011/01/11 20:17:39 UTC

svn commit: r1057807 - in /myfaces/current20/test-webapp/webapp/src/main: java/org/apache/myfaces/enumtest/EnumBean.java webapp/selectOneMenuEnum.xhtml webapp/selectOneMenuEnum2.xhtml

Author: lu4242
Date: Tue Jan 11 19:17:38 2011
New Revision: 1057807

URL: http://svn.apache.org/viewvc?rev=1057807&view=rev
Log:
MYFACES-2920 UISelectOne/UISelectMany validateValue: Before comparing each option, coerce the option value type to the type of component's value (some tests)

Added:
    myfaces/current20/test-webapp/webapp/src/main/webapp/selectOneMenuEnum.xhtml
    myfaces/current20/test-webapp/webapp/src/main/webapp/selectOneMenuEnum2.xhtml
Modified:
    myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java

Modified: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java?rev=1057807&r1=1057806&r2=1057807&view=diff
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java (original)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java Tue Jan 11 19:17:38 2011
@@ -18,6 +18,10 @@
  */
 package org.apache.myfaces.enumtest;
 
+import javax.annotation.PostConstruct;
+import javax.faces.convert.Converter;
+import javax.faces.convert.EnumConverter;
+
 public class EnumBean
 {
     
@@ -35,4 +39,69 @@ public class EnumBean
         return Actions.step3;
     }    
     
+    public enum Category {
+        ONE {
+
+            @Override
+            public String toString()
+            {
+                return "one";
+            } 
+            
+        },
+        TWO,
+        THREE {
+ 
+            @Override
+            public String toString()
+            {
+                return "three";
+            } 
+            
+        }
+    }
+    
+    private Category selection;
+    
+    private EnumConverter categoryConverter;
+    
+    @PostConstruct
+    public void init()
+    {
+        if (selection == null)
+        {
+            selection = Category.ONE;
+        }
+    }
+
+    public Category getSelection()
+    {
+        return selection;
+    }
+
+    public void setSelection(Category selection)
+    {
+        this.selection = selection;
+    }
+    
+    public String send()
+    {
+        return null;
+    }
+    
+    public Converter getCategoryConverter()
+    {
+        if (categoryConverter == null)
+        {
+            categoryConverter = new EnumConverter(Category.class);
+        }
+        return categoryConverter;
+    }
+    
+    public Category[] getCategories()
+    {
+        return Category.class.getEnumConstants();
+    }
+    
+    
 }

Added: myfaces/current20/test-webapp/webapp/src/main/webapp/selectOneMenuEnum.xhtml
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/webapp/selectOneMenuEnum.xhtml?rev=1057807&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/webapp/selectOneMenuEnum.xhtml (added)
+++ myfaces/current20/test-webapp/webapp/src/main/webapp/selectOneMenuEnum.xhtml Tue Jan 11 19:17:38 2011
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ >
+<h:head>
+</h:head>
+<h:body>
+    <h:outputStylesheet name="basic.css"/>
+    <h1>Myfaces Examples: Step 1</h1>
+    <h:messages></h:messages>
+    <h:form id="form">
+        <h:selectOneMenu value="#{enumBean.selection}">
+            <f:selectItem itemValue="ONE"/>
+            <f:selectItem itemValue="TWO"/>
+            <f:selectItem itemValue="THREE"/>
+        </h:selectOneMenu>
+    
+        <h:commandButton id="button1" value="press me" action="#{enumBean.send}" />
+    </h:form>
+</h:body>
+</html>

Added: myfaces/current20/test-webapp/webapp/src/main/webapp/selectOneMenuEnum2.xhtml
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/webapp/selectOneMenuEnum2.xhtml?rev=1057807&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/webapp/selectOneMenuEnum2.xhtml (added)
+++ myfaces/current20/test-webapp/webapp/src/main/webapp/selectOneMenuEnum2.xhtml Tue Jan 11 19:17:38 2011
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ >
+<h:head>
+</h:head>
+<h:body>
+    <h:outputStylesheet name="basic.css"/>
+    <h1>Myfaces Examples: Step 1</h1>
+    <h:messages></h:messages>
+    <h:form id="form">
+        <h:selectOneMenu value="#{enumBean.selection}" converter="#{enumBean.categoryConverter}">
+            <f:selectItems value="#{enumBean.categories}"/>
+            <!-- 
+            <f:selectItem itemValue="ONE"/>
+            <f:selectItem itemValue="TWO"/>
+            <f:selectItem itemValue="THREE"/>
+             -->
+        </h:selectOneMenu>
+    
+        <h:commandButton id="button1" value="press me" action="#{enumBean.send}" />
+    </h:form>
+</h:body>
+</html>