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 2010/11/26 21:02:34 UTC
svn commit: r1039540 [1/2] - in /myfaces/commons/branches/jsf_20/examples:
myfaces-commons-examples/
myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/
myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/...
Author: lu4242
Date: Fri Nov 26 20:02:33 2010
New Revision: 1039540
URL: http://svn.apache.org/viewvc?rev=1039540&view=rev
Log:
sync examples in jsf 2.0 branch
Added:
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/BooleanBean.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/DateTimeBean.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/NumberBean.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessTrackingVariableResolver.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessedBeans.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateCreditCard.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertBoolean.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertDateTime.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertNumber.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/creditcardvalidator.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/outputClientId.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateDateRestriction.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/BooleanBean.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/DateTimeBean.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/NumberBean.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessTrackingVariableResolver.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessedBeans.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/META-INF/
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/META-INF/templates/
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/META-INF/templates/footer.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/META-INF/templates/mbean_source.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/META-INF/templates/template.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/convertBoolean.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/convertDateTime.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/convertEnum.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/convertNumber.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/home.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/outputClientId.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/renderOne.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/validate.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/validateCSV.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/validateCompareTo.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/validateDateRestriction.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/validateUrl.xhtml
Modified:
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/pom.xml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/EducationLevel.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateEnum.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/WEB-INF/faces-config.xml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/WEB-INF/web.xml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertEnum.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/css/basic.css
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/exporter.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/home.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/inc/page_footer.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/renderOne.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validate.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateCSV.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateCompareTo.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateUrl.jsp
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/pom.xml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/validate/EducationLevel.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateCreditCard.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateEnum.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/servlet/SourceCodeServlet.java
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/WEB-INF/faces-config.xml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/WEB-INF/web.xml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/creditcardvalidator.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/css/basic.css
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/exporter.xhtml
myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/index.html
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/pom.xml?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/pom.xml (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/pom.xml Fri Nov 26 20:02:33 2010
@@ -30,6 +30,15 @@
<url>http://myfaces.apache.org</url>
<build>
<finalName>myfaces-commons-examples20</finalName>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>src/main/java</directory>
+ </resource>
+ </resources>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/BooleanBean.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/BooleanBean.java?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/BooleanBean.java (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/BooleanBean.java Fri Nov 26 20:02:33 2010
@@ -0,0 +1,45 @@
+/*
+ * 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.examples;
+
+
+public class BooleanBean
+{
+ private boolean way;
+
+ public BooleanBean()
+ {
+ }
+
+ public boolean getWay()
+ {
+ return way;
+ }
+
+ public void setWay(boolean way)
+ {
+ this.way = way;
+ }
+
+ public String submit()
+ {
+ System.out.println("Action was called.");
+ return ("valid");
+ }
+}
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/DateTimeBean.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/DateTimeBean.java?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/DateTimeBean.java (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/DateTimeBean.java Fri Nov 26 20:02:33 2010
@@ -0,0 +1,102 @@
+/*
+ * 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.examples;
+
+import java.util.Date;
+
+import javax.faces.component.UISelectOne;
+import javax.faces.context.FacesContext;
+
+public class DateTimeBean
+{
+ private String type;
+
+ private Date date1;
+
+ private Date date2;
+
+ private UISelectOne typeSelect;
+
+ public DateTimeBean()
+ {
+ date1 = new Date();
+ type = "both";
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public Date getDate1()
+ {
+ return date1;
+ }
+
+ public void setDate1(Date date1)
+ {
+ this.date1 = date1;
+ }
+
+ public Date getDate2()
+ {
+ return date2;
+ }
+
+ public void setDate2(Date date2)
+ {
+ this.date2 = date2;
+ }
+
+ public String[] getInvalidMonths()
+ {
+ return new String[]{"jan", "apr", "sep"};
+ }
+
+ public String submit()
+ {
+ System.out.println("Action was called.");
+ return ("valid");
+ }
+
+ public String getTypeFromSelect()
+ {
+ Object value = typeSelect.getValue();
+ if (value != null)
+ {
+ return value.toString();
+ }
+ return null;
+ }
+
+ public UISelectOne getTypeSelect()
+ {
+ return typeSelect;
+ }
+
+ public void setTypeSelect(UISelectOne typeSelect)
+ {
+ this.typeSelect = typeSelect;
+ }
+}
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/NumberBean.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/NumberBean.java?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/NumberBean.java (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/NumberBean.java Fri Nov 26 20:02:33 2010
@@ -0,0 +1,86 @@
+/*
+ * 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.examples;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UISelectOne;
+
+public class NumberBean
+{
+ private String type;
+
+ private Map<String, Double> numberMap;
+
+ private UISelectOne typeSelect;
+
+ public NumberBean()
+ {
+ numberMap = new HashMap<String, Double>();
+ numberMap.put("number1", 0.5d);
+ type = "percent";
+ }
+
+ public Map<String, Double> getNumberMap()
+ {
+ return numberMap;
+ }
+
+ public void setNumberMap(Map<String, Double> numberMap)
+ {
+ this.numberMap = numberMap;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public String submit()
+ {
+ System.out.println("Action was called.");
+ return ("valid");
+ }
+
+ public String getTypeFromSelect()
+ {
+ Object value = typeSelect.getValue();
+ if (value != null)
+ {
+ return value.toString();
+ }
+ return null;
+ }
+
+ public UISelectOne getTypeSelect()
+ {
+ return typeSelect;
+ }
+
+ public void setTypeSelect(UISelectOne typeSelect)
+ {
+ this.typeSelect = typeSelect;
+ }
+}
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessTrackingVariableResolver.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessTrackingVariableResolver.java?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessTrackingVariableResolver.java (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessTrackingVariableResolver.java Fri Nov 26 20:02:33 2010
@@ -0,0 +1,60 @@
+/*
+ * 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.examples.accessedbeans;
+
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.VariableResolver;
+
+/**
+ * @author Martin Marinschek (latest modification by $Author: matzew $)
+ * @version $Revision: 167718 $ $Date: 2005-03-24 17:47:11 +0100 (Do, 24 Mär 2005) $
+ */
+public class AccessTrackingVariableResolver extends VariableResolver
+{
+ private VariableResolver delegate;
+
+ /**Implementing delegate-pattern
+ *
+ * @param delegate Delegating to this instance.
+ */
+ public AccessTrackingVariableResolver(VariableResolver delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ // METHODS
+ public Object resolveVariable(FacesContext facesContext, String name) throws EvaluationException
+ {
+ Object resolvedBean = delegate.resolveVariable(facesContext, name);
+
+ if(!(resolvedBean instanceof AccessedBeans) && resolvedBean!=null)
+ {
+ if(!resolvedBean.getClass().getName().startsWith("java.lang.") && !(resolvedBean instanceof Map))
+ {
+ ((AccessedBeans) facesContext.getApplication().
+ getVariableResolver().resolveVariable(facesContext,"accessedBeans")).addBean(name, resolvedBean);
+ }
+ }
+
+ return resolvedBean;
+ }
+}
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessedBeans.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessedBeans.java?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessedBeans.java (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessedBeans.java Fri Nov 26 20:02:33 2010
@@ -0,0 +1,88 @@
+/*
+ * 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.examples.accessedbeans;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Martin Marinschek (latest modification by $Author: matzew $)
+ * @version $Revision: 167718 $ $Date: 2005-03-24 17:47:11 +0100 (Do, 24 Mär 2005) $
+ */
+public class AccessedBeans
+{
+ private List beanList;
+
+ public List getBeanList()
+ {
+ if(beanList == null)
+ beanList = new ArrayList();
+
+ return beanList;
+ }
+
+ public void setBeanList(List beanList)
+ {
+ this.beanList = beanList;
+ }
+
+ public void addBean(String name, Object resolvedBean)
+ {
+ List li = getBeanList();
+
+ for (int i = 0; i < li.size(); i++)
+ {
+ AccessedBean accessedBean = (AccessedBean) li.get(i);
+ if(accessedBean.getName().equals(name))
+ return;
+ }
+
+ AccessedBean bean = new AccessedBean();
+ bean.setName(name);
+ bean.setClazz(resolvedBean.getClass().getName());
+
+ li.add(bean);
+ }
+
+ public static class AccessedBean
+ {
+ private String name;
+ private String clazz;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getClazz()
+ {
+ return clazz;
+ }
+
+ public void setClazz(String clazz)
+ {
+ this.clazz = clazz;
+ }
+ }
+}
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/EducationLevel.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/EducationLevel.java?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/EducationLevel.java (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/EducationLevel.java Fri Nov 26 20:02:33 2010
@@ -26,4 +26,4 @@ public enum EducationLevel
UNIVERSITY,
MASTER,
DOCTOR
-}
+}
\ No newline at end of file
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateCreditCard.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateCreditCard.java?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateCreditCard.java (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateCreditCard.java Fri Nov 26 20:02:33 2010
@@ -0,0 +1,119 @@
+/*
+ * 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.examples.validate;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UISelectOne;
+import javax.faces.context.FacesContext;
+import javax.faces.model.SelectItem;
+
+/**
+ * @author mwessendorf
+ * @version $Revision: 673801 $ $Date: 2008-07-03 22:58:48 +0200 (Thu, 03 Jul 2008) $
+ */
+public class ValidateCreditCard {
+
+ private String creditCardNumber = null;
+
+ private String creditCardType = "MASTERCARD";
+
+ private List<SelectItem> types = null;
+
+ private UISelectOne creditCardTypeSelect;
+
+ public List<SelectItem> getCreditCardTypes()
+ {
+ if (types == null)
+ {
+ types = new ArrayList<SelectItem>();
+ types.add(new SelectItem("MASTERCARD"));
+ types.add(new SelectItem("VISA"));
+ types.add(new SelectItem("DISCOVER"));
+ types.add(new SelectItem("AMEX"));
+ }
+ return types;
+ }
+
+ public String submit(){
+ System.out.println("Action was called.");
+ FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("The selected credit card type/number is valid"));
+ return ("valid");
+ }
+
+ public String getCreditCardNumber() {
+ return creditCardNumber;
+ }
+
+ public void setCreditCardNumber(String string) {
+ creditCardNumber = string;
+ }
+
+ public String getCreditCardType()
+ {
+ return creditCardType;
+ }
+
+ public void setCreditCardType(String creditCardType)
+ {
+ this.creditCardType = creditCardType;
+ }
+
+ public boolean isAmex()
+ {
+ return "AMEX".equalsIgnoreCase(creditCardType);
+ }
+
+ public boolean isVisa()
+ {
+ return "VISA".equalsIgnoreCase(creditCardType);
+ }
+
+ public boolean isMastercard()
+ {
+ return "MASTERCARD".equalsIgnoreCase(creditCardType);
+ }
+
+ public boolean isDiscover()
+ {
+ return "DISCOVER".equalsIgnoreCase(creditCardType);
+ }
+
+ public UISelectOne getCreditCardTypeSelect()
+ {
+ return creditCardTypeSelect;
+ }
+
+ public void setCreditCardTypeSelect(UISelectOne creditCardTypeSelect)
+ {
+ this.creditCardTypeSelect = creditCardTypeSelect;
+ }
+
+ public String getCreditCardTypeFromSelect()
+ {
+ Object value = creditCardTypeSelect.getValue();
+ if (value != null)
+ {
+ return value.toString();
+ }
+ return null;
+ }
+}
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateEnum.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateEnum.java?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateEnum.java (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/java/org/apache/myfaces/commons/examples/validate/ValidateEnum.java Fri Nov 26 20:02:33 2010
@@ -18,6 +18,9 @@
*/
package org.apache.myfaces.commons.examples.validate;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+
public class ValidateEnum
{
@@ -33,4 +36,9 @@ public class ValidateEnum
this.level = level;
}
+ public String submit(){
+ System.out.println("Action was called.");
+ FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("The selected value is valid"));
+ return ("valid");
+ }
}
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties Fri Nov 26 20:02:33 2010
@@ -1,6 +1,8 @@
button_submit = Submit
email_comma = Email separated by ,
credit_dot = Credit Card separated by .
+credit_number = Insert a credit card number
+credit_type = Please select one card type
url_comma = Url separated by ,
isbn_semicolon = ISBN separated by ;
validate_email = Email
@@ -15,4 +17,5 @@ validate_notequal = Validate Not Equal
validate_greaterthan = Validate Greater Than
validate_greaterthanequal = Validate Greater Than Equal
validate_lessthan = Validate Less Than
-validate_lessthanequal =Validate Less Than Equal
\ No newline at end of file
+validate_lessthanequal =Validate Less Than Equal
+title=Myfaces Commons Example
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/WEB-INF/faces-config.xml?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/WEB-INF/faces-config.xml Fri Nov 26 20:02:33 2010
@@ -2,6 +2,18 @@
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+
+ <!-- from project setup -->
+ <application>
+ <variable-resolver>org.apache.myfaces.commons.examples.accessedbeans.AccessTrackingVariableResolver</variable-resolver>
+ </application>
+
+ <!-- Accessed beans on the last request -->
+ <managed-bean>
+ <managed-bean-name>accessedBeans</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.commons.examples.accessedbeans.AccessedBeans</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
<managed-bean>
<managed-bean-name>dataFieldHolder</managed-bean-name>
<managed-bean-class>org.apache.myfaces.commons.examples.DataFieldHolder</managed-bean-class>
@@ -28,4 +40,28 @@
<managed-bean-class>org.apache.myfaces.commons.renderone.RenderOneBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>validateCreditCard</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.commons.examples.validate.ValidateCreditCard</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>dateTimeBean</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.commons.examples.DateTimeBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>numberBean</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.commons.examples.NumberBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>booleanBean</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.commons.examples.BooleanBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
</faces-config>
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/WEB-INF/web.xml?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/WEB-INF/web.xml Fri Nov 26 20:02:33 2010
@@ -130,16 +130,17 @@
<load-on-startup>1</load-on-startup>
</servlet>
- <servlet>
- <servlet-name>SourceCodeServlet</servlet-name>
- <servlet-class>org.apache.myfaces.commons.servlet.SourceCodeServlet</servlet-class>
- </servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
+
+ <servlet>
+ <servlet-name>SourceCodeServlet</servlet-name>
+ <servlet-class>org.apache.myfaces.commons.servlet.SourceCodeServlet</servlet-class>
+ </servlet>
<servlet-mapping>
<servlet-name>SourceCodeServlet</servlet-name>
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertBoolean.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertBoolean.jsp?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertBoolean.jsp (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertBoolean.jsp Fri Nov 26 20:02:33 2010
@@ -0,0 +1,76 @@
+<%@ 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/components"
+ prefix="mc"%>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators"
+ prefix="mcv"%>
+
+<html>
+<f:view>
+
+<%@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>
+<div id="container">
+ <f:loadBundle
+ basename="org.apache.myfaces.examples.resource.example_messages"
+ var="example_messages" />
+
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
+ <h:panelGroup id="body">
+ <p>This example check how mcc:convertBoolean works. This converter
+ translates between boolean values (true/false)
+ and alternate versions of those boolean values like
+ (yes/no), (1/0), and (way/no way).</p>
+ <h:form id="form1">
+ <h:messages showDetail="false" showSummary="true" ></h:messages>
+ <p>Current value: <h:outputText value="#{booleanBean.way}"/></p>
+ <h:panelGrid columns="3">
+
+ <h:outputLabel for="boolVal" value="" />
+ <h:inputText id="boolVal" value="#{booleanBean.way}" required="true">
+ <mcc:convertBoolean trueValue="way" falseValue="no way" />
+ </h:inputText>
+ <h:message for="boolVal" styleClass="error" />
+
+ <h:panelGroup />
+ <h:commandButton id="validateButton"
+ value="#{example_messages['button_submit']}"
+ action="#{booleanBean.submit}" />
+ <h:panelGroup />
+
+ </h:panelGrid>
+ </h:form>
+
+ </h:panelGroup>
+<%@include file="inc/page_footer.jsp"%>
+</div>
+</body>
+
+</f:view>
+</html>
\ No newline at end of file
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertDateTime.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertDateTime.jsp?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertDateTime.jsp (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertDateTime.jsp Fri Nov 26 20:02:33 2010
@@ -0,0 +1,86 @@
+<%@ 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/components"
+ prefix="mc"%>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators"
+ prefix="mcv"%>
+
+<html>
+<f:view>
+
+<%@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>
+<div id="container">
+ <f:loadBundle
+ basename="org.apache.myfaces.examples.resource.example_messages"
+ var="example_messages" />
+
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
+ <h:panelGroup id="body">
+ <p>This example shows how mcc:convertDateTime component works. It works almost
+ the same as f:convertDateTime, but it has as TimeZone default
+ TimeZone.getDefault() instead GMT and it evaluate EL expressions when the value
+ is being validated instead when the converter is built. </p>
+ <p>Current Locale: <h:outputText value="#{facesContext.viewRoot.locale}"/></p>
+ <h:form id="form1">
+ <h:messages showDetail="false" showSummary="true" ></h:messages>
+ <h:panelGrid columns="3">
+
+ <h:outputLabel for="type"
+ value="Insert a type" />
+ <h:selectOneMenu id="type" immediate="true" value="#{dateTimeBean.type}" binding="#{dateTimeBean.typeSelect}" >
+ <f:selectItem itemLabel="date" itemValue="date"/>
+ <f:selectItem itemLabel="time" itemValue="time"/>
+ <f:selectItem itemLabel="both" itemValue="both"/>
+ </h:selectOneMenu>
+ <h:message for="type" styleClass="error" />
+
+ <h:outputLabel for="date1"
+ value="Insert a date/time" />
+ <h:inputText id="date1" value="#{dateTimeBean.date1}" required="true">
+ <mcc:convertDateTime type="#{dateTimeBean.typeFromSelect}"/>
+ </h:inputText>
+ <h:message for="date1" styleClass="error" />
+
+ <h:panelGroup />
+ <h:commandButton id="validateButton"
+ value="#{example_messages['button_submit']}"
+ action="#{dateTimeBean.submit}" />
+ <h:panelGroup />
+
+ </h:panelGrid>
+ </h:form>
+
+ </h:panelGroup>
+<%@include file="inc/page_footer.jsp"%>
+</div>
+</body>
+
+</f:view>
+</html>
\ No newline at end of file
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertEnum.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertEnum.jsp?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertEnum.jsp (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertEnum.jsp Fri Nov 26 20:02:33 2010
@@ -3,10 +3,13 @@
<%@ 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/components"
+ prefix="mc"%>
<%@ taglib uri="http://myfaces.apache.org/commons/validators"
prefix="mcv"%>
<html>
+<f:view>
<%@include file="inc/head.inc"%>
@@ -32,17 +35,18 @@
//-->
<body>
+<div id="container">
+ <f:loadBundle
+ basename="org.apache.myfaces.examples.resource.example_messages"
+ var="example_messages" />
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
<!--
managed beans used:
validateForm
-->
-<f:view>
-
- <f:loadBundle
- basename="org.apache.myfaces.examples.resource.example_messages"
- var="example_messages" />
<h:panelGroup id="body">
@@ -54,7 +58,7 @@ managed beans used:
value="#{example_messages['validate_enum']}" />
<h:inputText id="enum" value="#{validateEnum.level}" required="true">
<mcc:convertEnum
- targetClass="org.apache.myfaces.examples.validate.EducationLevel" />
+ targetClass="org.apache.myfaces.commons.examples.validate.EducationLevel" />
</h:inputText>
<h:message id="enumError" for="enum" styleClass="error" />
@@ -69,10 +73,10 @@ managed beans used:
</h:panelGroup>
-</f:view>
<%@include file="inc/page_footer.jsp"%>
-
+</div>
</body>
+</f:view>
</html>
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertNumber.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertNumber.jsp?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertNumber.jsp (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/convertNumber.jsp Fri Nov 26 20:02:33 2010
@@ -0,0 +1,87 @@
+<%@ 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/components"
+ prefix="mc"%>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators"
+ prefix="mcv"%>
+
+<html>
+<f:view>
+
+<%@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>
+<div id="container">
+ <f:loadBundle
+ basename="org.apache.myfaces.examples.resource.example_messages"
+ var="example_messages" />
+
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
+ <h:panelGroup id="body">
+ <p>This example shows how mcc:convertNumber component works. It works almost
+ the same as f:convertNumber, but it has "destType" attribute that define the
+ target attribute to the backing bean property (useful when maps are used because
+ ValueExpression.getType return null) and it evaluate EL expressions when the value
+ is being validated instead when the converter is built. </p>
+ <p>Current Locale: <h:outputText value="#{facesContext.viewRoot.locale}"/></p>
+ <h:form id="form1">
+ <h:messages showDetail="false" showSummary="true" ></h:messages>
+ <h:panelGrid columns="3">
+
+ <h:outputLabel for="type"
+ value="Insert a type" />
+ <h:selectOneMenu id="type" immediate="true" value="#{numberBean.type}" binding="#{numberBean.typeSelect}" >
+ <f:selectItem itemLabel="number" itemValue="number"/>
+ <f:selectItem itemLabel="currency" itemValue="currency"/>
+ <f:selectItem itemLabel="percent" itemValue="percent"/>
+ </h:selectOneMenu>
+ <h:message for="type" styleClass="error" />
+
+ <h:outputLabel for="number1"
+ value="Insert a number" />
+ <h:inputText id="number1" value="#{numberBean.numberMap['number1']}" required="true">
+ <mcc:convertNumber destType="java.lang.Double" type="#{numberBean.typeFromSelect}"/>
+ </h:inputText>
+ <h:message for="number1" styleClass="error" />
+
+ <h:panelGroup />
+ <h:commandButton id="validateButton"
+ value="#{example_messages['button_submit']}"
+ action="#{numberBean.submit}" />
+ <h:panelGroup />
+
+ </h:panelGrid>
+ </h:form>
+
+ </h:panelGroup>
+<%@include file="inc/page_footer.jsp"%>
+</div>
+</body>
+
+</f:view>
+</html>
\ No newline at end of file
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/creditcardvalidator.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/creditcardvalidator.jsp?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/creditcardvalidator.jsp (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/creditcardvalidator.jsp Fri Nov 26 20:02:33 2010
@@ -0,0 +1,87 @@
+<%@ 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/components"
+ prefix="mc"%>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators"
+ prefix="mcv"%>
+
+<html>
+<f:view>
+
+<%@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>
+<div id="container">
+ <f:loadBundle
+ basename="org.apache.myfaces.examples.resource.example_messages"
+ var="example_messages" />
+
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
+ <h:messages showDetail="true" showSummary="false"/>
+
+ <h:form id="myform">
+ <p>Some valid test numbers</p>
+
+ <ul>
+ <li>Mastercard : 5555555555554444</li>
+ <li>Mastercard : 5105105105105100</li>
+ <li>Visa : 4111111111111111</li>
+ <li>Visa : 4111111111111111</li>
+ <li>Discover : 6011111111111117</li>
+ <li>Discover : 6011000990139424</li>
+ <li>American Express : 378282246310005</li>
+ <li>American Express : 371449635398431</li>
+ </ul>
+
+ <h:panelGrid columns ="3">
+ <h:outputLabel for="creditCardType" value="#{example_messages['credit_type']}" />
+ <h:selectOneRadio id="creditCardType" value="#{validateCreditCard.creditCardType}" immediate="true" binding="#{validateCreditCard.creditCardTypeSelect}">
+ <f:selectItems value="#{validateCreditCard.creditCardTypes}"/>
+ </h:selectOneRadio>
+ <h:message id="creditCardTypeError" for="creditCardType" styleClass="error" />
+
+ <h:outputLabel for="creditCardNumber" value="#{example_messages['credit_number']}" />
+ <h:inputText id="creditCardNumber" value="#{validateCreditCard.creditCardNumber}" required="true">
+ <mcv:validateCreditCard
+ amex="#{validateCreditCard.creditCardTypeFromSelect == 'AMEX'}"
+ visa="#{validateCreditCard.creditCardTypeFromSelect == 'VISA'}"
+ discover="#{validateCreditCard.creditCardTypeFromSelect == 'DISCOVER'}"
+ mastercard="#{validateCreditCard.creditCardTypeFromSelect == 'MASTERCARD'}" />
+ </h:inputText>
+ <h:message id="creditCardNumberError" for="creditCardNumber" styleClass="error" />
+ </h:panelGrid>
+ <h:panelGroup/>
+ <h:commandButton id="validateButton" value="#{example_messages['button_submit']}" action="#{validateCreditCard.submit}"/>
+ <h:panelGroup/>
+ </h:form>
+<%@include file="inc/page_footer.jsp"%>
+</div>
+</body>
+
+</f:view>
+</html>
\ No newline at end of file
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/css/basic.css
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/css/basic.css?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/css/basic.css (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/css/basic.css Fri Nov 26 20:02:33 2010
@@ -1,8 +1,20 @@
body {
- font-family : arial, verdana, Geneva, Arial, Helvetica, sans-serif;
+ background-color: rgb(0, 35, 75);
+ font-family : arial, verdana, Geneva, Arial, Helvetica, sans-serif;
font-size : 12px;
}
+#container {
+ margin: 10px auto;
+ width: 900px;
+ background-color: white;
+ padding: 3px;
+}
+
+h1 {
+ font-size: 20px;
+}
+
.standard {
font-family : verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/exporter.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/exporter.jsp?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/exporter.jsp (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/exporter.jsp Fri Nov 26 20:02:33 2010
@@ -1,10 +1,17 @@
-<%@ 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/components" prefix="mc" %>
+<%@ 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/components"
+ prefix="mc"%>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators"
+ prefix="mcv"%>
+
<html>
+<f:view>
-<%@ include file="inc/head.inc" %>
+<%@include file="inc/head.inc"%>
<!--
/*
@@ -28,9 +35,13 @@
//-->
<body>
+<div id="container">
+ <f:loadBundle
+ basename="org.apache.myfaces.examples.resource.example_messages"
+ var="example_messages" />
-<f:view>
-
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
<h:form>
<p>This component allows to export the datatable contents to an excel or pdf file.</p>
@@ -81,10 +92,10 @@
</h:form>
-</f:view>
-<%@ include file="inc/page_footer.jsp" %>
+<%@ include file="inc/page_footer.jsp" %>
+</div>
</body>
-
+</f:view>
</html>
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/home.jsp?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/home.jsp (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/home.jsp Fri Nov 26 20:02:33 2010
@@ -4,7 +4,7 @@
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<html>
-
+<f:view>
<!--
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -30,40 +30,38 @@
<body>
-<f:view>
-
+<div id="container">
<f:loadBundle
basename="org.apache.myfaces.examples.resource.example_messages"
var="example_messages" />
+ <h:panelGrid id="header_group1" columns="2" styleClass="pageHeader" >
+ <h:panelGroup>
+ <h:outputText style="font-size:20px;color:#FFFFFF" escape="false" value="MyFaces - The free JavaServer™ Faces Implementation - Myfaces Commons JSP Example"/>
+ </h:panelGroup>
+ </h:panelGrid>
+
<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:outputLink value="validateUrl.jsf">
- <f:verbatim>ValidateUrl</f:verbatim>
- </h:outputLink>
- <h:outputLink value="convertEnum.jsf">
- <f:verbatim>ConvertEnum</f:verbatim>
- </h:outputLink>
- <h:outputLink value="renderOne.jsf">
- <f:verbatim>renderOne - render the first child component by order or by index</f:verbatim>
- </h:outputLink>
- <h:outputLink value="exporter.jsf">
- <f:verbatim>Exporter - Export datatable contents as an excel file or as a pdf file</f:verbatim>
- </h:outputLink>
- </h:panelGrid>
- </h:form>
+ <h:panelGrid>
+ <h:outputLink value="convertBoolean.jsf" ><f:verbatim>mcc:convertBoolean</f:verbatim></h:outputLink>
+ <h:outputLink value="convertEnum.jsf" ><f:verbatim>mcc:convertEnum</f:verbatim></h:outputLink>
+ <h:outputLink value="convertNumber.jsf" ><f:verbatim>mcc:convertNumber</f:verbatim></h:outputLink>
+ <h:outputLink value="convertDateTime.jsf" ><f:verbatim>mcc:convertDateTime</f:verbatim></h:outputLink>
+ <h:outputLink value="creditcardvalidator.jsf" ><f:verbatim>mcv:validateCreditCard</f:verbatim></h:outputLink>
+ <h:outputLink value="validate.jsf" ><f:verbatim>Multiple Validations (Email, Credit Card, Regex)</f:verbatim></h:outputLink>
+ <h:outputLink value="validateCompareTo.jsf" ><f:verbatim>mcv:validateCompareTo</f:verbatim></h:outputLink>
+ <h:outputLink value="validateCSV.jsf" ><f:verbatim>mcv:validateCSV</f:verbatim></h:outputLink>
+ <h:outputLink value="validateUrl.jsf" ><f:verbatim>mcv:validateUrl</f:verbatim></h:outputLink>
+ <h:outputLink value="validateDateRestriction.jsf" ><f:verbatim>mcv:validateDateRestriction</f:verbatim></h:outputLink>
+ <h:outputLink value="exporter.jsf" ><f:verbatim>Exporter - Export datatable contents as an excel file or as a pdf file</f:verbatim></h:outputLink>
+ <h:outputLink value="renderOne.jsf" ><f:verbatim>mc:renderOne - render the first child component by order or by index</f:verbatim></h:outputLink>
+ <h:outputLink value="outputClientId.jsf" ><f:verbatim>mc:outputClientId</f:verbatim></h:outputLink>
+ </h:panelGrid>
-</f:view>
+ </h:form>
+</div>
</body>
-</html>
\ No newline at end of file
+</f:view>
+</html>
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/inc/page_footer.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/inc/page_footer.jsp?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/inc/page_footer.jsp (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/inc/page_footer.jsp Fri Nov 26 20:02:33 2010
@@ -1,3 +1,15 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<h:dataTable value="#{accessedBeans.beanList}" var="accessedBean">
+ <h:column>
+ <h:outputLink value="#{accessedBean.clazz}.java.source" >
+ <h:outputText value="Usage of bean with name : "/>
+ <h:outputText value="#{accessedBean.name}"/>
+ <h:outputText value=" and class : "/>
+ <h:outputText value="#{accessedBean.clazz}"/>
+ </h:outputLink>
+ </h:column>
+</h:dataTable>
<br/>
<br/>
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/outputClientId.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/outputClientId.jsp?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/outputClientId.jsp (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/outputClientId.jsp Fri Nov 26 20:02:33 2010
@@ -0,0 +1,70 @@
+<%@ 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/components"
+ prefix="mc"%>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators"
+ prefix="mcv"%>
+
+<html>
+<f:view>
+
+<%@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>
+<div id="container">
+ <f:loadBundle
+ basename="org.apache.myfaces.examples.resource.example_messages"
+ var="example_messages" />
+
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
+
+ <h:messages showDetail="true" showSummary="false"/>
+
+ <p>
+ <a href="javascript:void" onclick="testJavascript(event);return false;">Test link</a>
+
+ <script type="text/javascript">
+ function testJavascript(event) {
+ var element = document.getElementById('<mc:outputClientId for="myContainer" />');
+ }
+ </script>
+ </p>
+
+ <h:form id="myContainer">
+ mc:outputClientId is useful when a component id is needed as reference within an inline javascript.
+ <ul>
+ <li>ClientId of containing container is <code><mc:outputClientId for="myContainer"/></code></li>
+ <li>ClientId of current parent is <code><mc:outputClientId /></code></li>
+ </ul>
+ </h:form>
+<%@include file="inc/page_footer.jsp"%>
+</div>
+</body>
+
+</f:view>
+</html>
\ No newline at end of file
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/renderOne.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/renderOne.jsp?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/renderOne.jsp (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/renderOne.jsp Fri Nov 26 20:02:33 2010
@@ -1,8 +1,17 @@
-<%@ 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/components" prefix="mc" %>
+<%@ 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/components"
+ prefix="mc"%>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators"
+ prefix="mcv"%>
+
<html>
+<f:view>
+
+<%@include file="inc/head.inc"%>
<!--
/*
@@ -25,10 +34,14 @@
*/
//-->
-<%@include file="inc/head.inc" %>
-
<body>
-<f:view>
+<div id="container">
+ <f:loadBundle
+ basename="org.apache.myfaces.examples.resource.example_messages"
+ var="example_messages" />
+
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
<h:form>
<h:outputText value="Output:" />
@@ -52,9 +65,9 @@
</h:panelGrid>
</h:form>
-</f:view>
<%@include file="inc/page_footer.jsp" %>
-
+</div>
</body>
+</f:view>
</html>
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validate.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validate.jsp?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validate.jsp (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validate.jsp Fri Nov 26 20:02:33 2010
@@ -6,6 +6,7 @@
<%@ taglib uri="http://myfaces.apache.org/commons/converters" prefix="mcc" %>
<%@ taglib uri="http://myfaces.apache.org/commons/validators" prefix="mcv" %>
<html>
+<f:view>
<%@ include file="inc/head.inc" %>
@@ -31,15 +32,17 @@
//-->
<body>
+<div id="container">
+ <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
+
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
<!--
managed beans used:
validateForm
-->
-<f:view>
-
- <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
<h:panelGroup id="body">
@@ -82,10 +85,10 @@ managed beans used:
</h:panelGroup>
-</f:view>
<%@ include file="inc/page_footer.jsp" %>
-
+</div>
</body>
+</f:view>
</html>
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateCSV.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateCSV.jsp?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateCSV.jsp (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateCSV.jsp Fri Nov 26 20:02:33 2010
@@ -5,6 +5,7 @@
<%@ taglib uri="http://myfaces.apache.org/commons/validators" prefix="mcv" %>
<html>
+<f:view>
<%@include file="inc/head.inc" %>
@@ -30,16 +31,17 @@
//-->
<body>
+<div id="container">
+ <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
+
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
<!--
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"/>
@@ -68,10 +70,10 @@ managed beans used:
</h:panelGroup>
-</f:view>
<%@include file="inc/page_footer.jsp" %>
-
+</div>
</body>
+</f:view>
</html>
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateCompareTo.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateCompareTo.jsp?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateCompareTo.jsp (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateCompareTo.jsp Fri Nov 26 20:02:33 2010
@@ -5,6 +5,7 @@
<%@ taglib uri="http://myfaces.apache.org/commons/validators" prefix="mcv" %>
<html>
+<f:view>
<%@include file="inc/head.inc" %>
@@ -30,15 +31,17 @@
//-->
<body>
+<div id="container">
+ <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
+
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
<!--
managed beans used:
validateForm
-->
-<f:view>
-
- <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
<h:panelGroup id="body">
@@ -96,10 +99,9 @@ managed beans used:
</h:panelGroup>
-</f:view>
<%@include file="inc/page_footer.jsp" %>
-
+</div>
</body>
-
+</f:view>
</html>
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateDateRestriction.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateDateRestriction.jsp?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateDateRestriction.jsp (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateDateRestriction.jsp Fri Nov 26 20:02:33 2010
@@ -0,0 +1,76 @@
+<%@ 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/components"
+ prefix="mc"%>
+<%@ taglib uri="http://myfaces.apache.org/commons/validators"
+ prefix="mcv"%>
+
+<html>
+<f:view>
+
+<%@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>
+<div id="container">
+ <f:loadBundle
+ basename="org.apache.myfaces.examples.resource.example_messages"
+ var="example_messages" />
+
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
+ <h:panelGroup id="body">
+ <p>This example shows how mcv:validateDateRestriction validator works. It checks
+ if a date is outside a restriction indicated by invalidMonths, invalidDaysOfWeek or invalidDays</p>
+ <p>Current Locale: <h:outputText value="#{facesContext.viewRoot.locale}"/></p>
+ <h:form id="form1">
+ <h:messages showDetail="false" showSummary="true" ></h:messages>
+ <h:panelGrid columns="3">
+
+ <h:outputLabel for="date1"
+ value="Insert a date (yyyy/MM/dd) [months jan, apr, sep are invalid and if fall on saturday or sunday(sat sun) ]" />
+ <h:inputText id="date1" value="#{dateTimeBean.date1}" required="true">
+ <mcc:convertDateTime pattern="yyyy/MM/dd"/>
+ <mcv:validateDateRestriction invalidMonths="#{dateTimeBean.invalidMonths}" invalidDaysOfWeek="sat sun"/>
+ </h:inputText>
+ <h:message for="date1" styleClass="error" />
+
+ <h:panelGroup />
+ <h:commandButton id="validateButton"
+ value="#{example_messages['button_submit']}"
+ action="#{dateTimeBean.submit}" />
+ <h:panelGroup />
+
+ </h:panelGrid>
+ </h:form>
+
+ </h:panelGroup>
+<%@include file="inc/page_footer.jsp"%>
+</div>
+</body>
+
+</f:view>
+</html>
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateUrl.jsp
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateUrl.jsp?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateUrl.jsp (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-examples/src/main/webapp/validateUrl.jsp Fri Nov 26 20:02:33 2010
@@ -5,6 +5,7 @@
<%@ taglib uri="http://myfaces.apache.org/commons/validators" prefix="mcv" %>
<html>
+<f:view>
<%@include file="inc/head.inc" %>
@@ -30,15 +31,17 @@
//-->
<body>
+<div id="container">
+ <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
+
+ <h1><h:outputText value="#{example_messages['title']}"/></h1>
+ <br/>
<!--
managed beans used:
validateForm
-->
-<f:view>
-
- <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
<h:panelGroup id="body">
@@ -60,10 +63,9 @@ managed beans used:
</h:panelGroup>
-</f:view>
<%@include file="inc/page_footer.jsp" %>
-
+</div>
</body>
-
+</f:view>
</html>
Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/pom.xml?rev=1039540&r1=1039539&r2=1039540&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/pom.xml (original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/pom.xml Fri Nov 26 20:02:33 2010
@@ -30,6 +30,15 @@
<url>http://myfaces.apache.org</url>
<build>
<finalName>myfaces-commons-facelets-examples20</finalName>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>src/main/java</directory>
+ </resource>
+ </resources>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
@@ -106,4 +115,4 @@
<artifactId>junit</artifactId>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/BooleanBean.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/BooleanBean.java?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/BooleanBean.java (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/BooleanBean.java Fri Nov 26 20:02:33 2010
@@ -0,0 +1,45 @@
+/*
+ * 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.examples;
+
+
+public class BooleanBean
+{
+ private boolean way;
+
+ public BooleanBean()
+ {
+ }
+
+ public boolean getWay()
+ {
+ return way;
+ }
+
+ public void setWay(boolean way)
+ {
+ this.way = way;
+ }
+
+ public String submit()
+ {
+ System.out.println("Action was called.");
+ return ("valid");
+ }
+}
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/DateTimeBean.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/DateTimeBean.java?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/DateTimeBean.java (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/DateTimeBean.java Fri Nov 26 20:02:33 2010
@@ -0,0 +1,101 @@
+/*
+ * 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.examples;
+
+import java.util.Date;
+
+import javax.faces.component.UISelectOne;
+
+public class DateTimeBean
+{
+ private String type;
+
+ private Date date1;
+
+ private Date date2;
+
+ private UISelectOne typeSelect;
+
+ public DateTimeBean()
+ {
+ date1 = new Date();
+ type = "both";
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public Date getDate1()
+ {
+ return date1;
+ }
+
+ public void setDate1(Date date1)
+ {
+ this.date1 = date1;
+ }
+
+ public Date getDate2()
+ {
+ return date2;
+ }
+
+ public void setDate2(Date date2)
+ {
+ this.date2 = date2;
+ }
+
+ public String[] getInvalidMonths()
+ {
+ return new String[]{"jan", "apr", "sep"};
+ }
+
+ public String submit()
+ {
+ System.out.println("Action was called.");
+ return ("valid");
+ }
+
+ public String getTypeFromSelect()
+ {
+ Object value = typeSelect.getValue();
+ if (value != null)
+ {
+ return value.toString();
+ }
+ return null;
+ }
+
+ public UISelectOne getTypeSelect()
+ {
+ return typeSelect;
+ }
+
+ public void setTypeSelect(UISelectOne typeSelect)
+ {
+ this.typeSelect = typeSelect;
+ }
+}
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/NumberBean.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/NumberBean.java?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/NumberBean.java (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/NumberBean.java Fri Nov 26 20:02:33 2010
@@ -0,0 +1,86 @@
+/*
+ * 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.examples;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UISelectOne;
+
+public class NumberBean
+{
+ private String type;
+
+ private Map<String, Double> numberMap;
+
+ private UISelectOne typeSelect;
+
+ public NumberBean()
+ {
+ numberMap = new HashMap<String, Double>();
+ numberMap.put("number1", 0.5d);
+ type = "percent";
+ }
+
+ public Map<String, Double> getNumberMap()
+ {
+ return numberMap;
+ }
+
+ public void setNumberMap(Map<String, Double> numberMap)
+ {
+ this.numberMap = numberMap;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public String submit()
+ {
+ System.out.println("Action was called.");
+ return ("valid");
+ }
+
+ public String getTypeFromSelect()
+ {
+ Object value = typeSelect.getValue();
+ if (value != null)
+ {
+ return value.toString();
+ }
+ return null;
+ }
+
+ public UISelectOne getTypeSelect()
+ {
+ return typeSelect;
+ }
+
+ public void setTypeSelect(UISelectOne typeSelect)
+ {
+ this.typeSelect = typeSelect;
+ }
+}
Added: myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessTrackingVariableResolver.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessTrackingVariableResolver.java?rev=1039540&view=auto
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessTrackingVariableResolver.java (added)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/java/org/apache/myfaces/commons/examples/accessedbeans/AccessTrackingVariableResolver.java Fri Nov 26 20:02:33 2010
@@ -0,0 +1,60 @@
+/*
+ * 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.examples.accessedbeans;
+
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.VariableResolver;
+
+/**
+ * @author Martin Marinschek (latest modification by $Author: matzew $)
+ * @version $Revision: 167718 $ $Date: 2005-03-24 17:47:11 +0100 (Do, 24 Mär 2005) $
+ */
+public class AccessTrackingVariableResolver extends VariableResolver
+{
+ private VariableResolver delegate;
+
+ /**Implementing delegate-pattern
+ *
+ * @param delegate Delegating to this instance.
+ */
+ public AccessTrackingVariableResolver(VariableResolver delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ // METHODS
+ public Object resolveVariable(FacesContext facesContext, String name) throws EvaluationException
+ {
+ Object resolvedBean = delegate.resolveVariable(facesContext, name);
+
+ if(!(resolvedBean instanceof AccessedBeans) && resolvedBean!=null)
+ {
+ if(!resolvedBean.getClass().getName().startsWith("java.lang.") && !(resolvedBean instanceof Map))
+ {
+ ((AccessedBeans) facesContext.getApplication().
+ getVariableResolver().resolveVariable(facesContext,"accessedBeans")).addBean(name, resolvedBean);
+ }
+ }
+
+ return resolvedBean;
+ }
+}