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/01/28 03:03:55 UTC
svn commit: r903939 [1/4] - in /myfaces/current20/test-webapp/webapp: ./
src/main/java/org/apache/myfaces/bindingCLV/
src/main/java/org/apache/myfaces/blank/
src/main/java/org/apache/myfaces/convertDateTime/
src/main/java/org/apache/myfaces/convertbig/...
Author: lu4242
Date: Thu Jan 28 02:03:43 2010
New Revision: 903939
URL: http://svn.apache.org/viewvc?rev=903939&view=rev
Log:
MYFACES-2513 Update examples from test web application 1.2 and merge with 2.0 (Thanks to Ingo Hofmann for provide this patch)
Added:
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/blank/HelloWorldBacking.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/blank/NumberBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertDateTime/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertbig/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/disabled/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/enumtest/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/listexample/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/listexample/SimpleCity.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountry.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryList.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/invoke/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/invoke/InvokeOnComponentBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/jstl/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/jstl/ListBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/phaseuiroot/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/phaseuiroot/PhaseMethodsUIRootBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/postback/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/postback/PostbackBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/renderkit/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/renderkit/CustomRenderKit.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/runtimeex/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/runtimeex/HelloWorldThrowExBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/selectItem/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/selectItem/SelectItemBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/selectItem/SelectItemEscapeBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/servlet/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/servlet/SourceCodeServlet.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/setprop/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/setprop/SetPropertyBean.java
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/test/
myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/test/Bean.java
myfaces/current20/test-webapp/webapp/src/main/resources/org/
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/build.properties
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_ca.properties
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_de.properties
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_en.properties
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_es.properties
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_fr.properties
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_ja.properties
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_pt_BR.properties
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_ru.properties
myfaces/current20/test-webapp/webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_zh.properties
myfaces/current20/test-webapp/webapp/src/main/resources/test/
myfaces/current20/test-webapp/webapp/src/main/resources/test/messages.properties
myfaces/current20/test-webapp/webapp/src/main/webapp/bindingCLV.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/bindingCLV2.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/bundleTest.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/bundleWithEL.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/column.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/comp2.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/comp2.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/comp3.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/comp3.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/comp4.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/comp4.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/convertBig.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/convertBig2.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/convertDateTime.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/detectPostback.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/disabledLink.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/flash1.xhtml
- copied, changed from r903924, myfaces/current20/test-webapp/webapp/src/main/webapp/flash1.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flash2.xhtml
- copied, changed from r903924, myfaces/current20/test-webapp/webapp/src/main/webapp/flash2.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flash3.xhtml
- copied, changed from r903924, myfaces/current20/test-webapp/webapp/src/main/webapp/flash3.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flashhw1.xhtml
- copied, changed from r903924, myfaces/current20/test-webapp/webapp/src/main/webapp/flashhw1.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flashhw2.xhtml
- copied, changed from r903924, myfaces/current20/test-webapp/webapp/src/main/webapp/flashhw2.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flashprg1.xhtml
- copied, changed from r903924, myfaces/current20/test-webapp/webapp/src/main/webapp/flashprg1.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flashprg2.xhtml
- copied, changed from r903924, myfaces/current20/test-webapp/webapp/src/main/webapp/flashprg2.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/forEach.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/forEachInclude.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/forEachInclude2.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/forEachInclude3.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/forEachInclude4.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/forEachTest.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/helloWorld2.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/hideShowRadio.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/home.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/imageCommand.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/invokeOnComponent.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/labelattribute.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/layoutMessages.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/layoutPanelGroup.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/multipleRenderKit.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/nullSelectItem.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/onclick.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/page.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/pageScope.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/phaseMethodsUIRoot.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/prettyOutRB.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/resources/
myfaces/current20/test-webapp/webapp/src/main/webapp/resources/basic.css
myfaces/current20/test-webapp/webapp/src/main/webapp/selectOneManyEscape.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/setProperty.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/step1.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/step2.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/step3.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/suppressRuntimeEx.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/test.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/test2.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/test3.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/verbatimRendered.xhtml
Removed:
myfaces/current20/test-webapp/webapp/src/main/webapp/flash1.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flash2.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flash3.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flashhw1.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flashhw2.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flashprg1.jsp
myfaces/current20/test-webapp/webapp/src/main/webapp/flashprg2.jsp
Modified:
myfaces/current20/test-webapp/webapp/pom.xml
myfaces/current20/test-webapp/webapp/src/main/webapp/WEB-INF/faces-config.xml
myfaces/current20/test-webapp/webapp/src/main/webapp/WEB-INF/web.xml
myfaces/current20/test-webapp/webapp/src/main/webapp/ajax2.xhtml
myfaces/current20/test-webapp/webapp/src/main/webapp/index.jsp
Modified: myfaces/current20/test-webapp/webapp/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/pom.xml?rev=903939&r1=903938&r2=903939&view=diff
==============================================================================
--- myfaces/current20/test-webapp/webapp/pom.xml (original)
+++ myfaces/current20/test-webapp/webapp/pom.xml Thu Jan 28 02:03:43 2010
@@ -47,6 +47,12 @@
<version>1.2</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.bindingCLV;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionListener;
+import javax.faces.webapp.UIComponentClassicTagBase;
+import javax.faces.webapp.UIComponentELTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.Tag;
+import javax.servlet.jsp.tagext.TagSupport;
+
+//import org.apache.myfaces.shared_impl.util.ClassUtils;
+
+/**
+ *
+ *
+ */
+public class ActionListenerImplTag
+ extends TagSupport
+{
+ private ValueExpression _type = null;
+ private ValueExpression _binding = null;
+
+ public ActionListenerImplTag()
+ {
+ super();
+ }
+
+ public void setType(ValueExpression type)
+ {
+ _type = type;
+ }
+
+ public void setBinding(ValueExpression binding)
+ {
+ _binding = binding;
+ }
+
+ public void release()
+ {
+ super.release();
+ _type = null;
+ _binding = null;
+ }
+
+ protected void addListener(ActionSource actionSource, ActionListener actionListener)
+ {
+ actionSource.addActionListener(actionListener);
+ }
+
+ public int doStartTag() throws JspException
+ {
+ UIComponentClassicTagBase componentTag = UIComponentELTag.getParentUIComponentClassicTagBase(pageContext);
+ if (componentTag == null)
+ {
+ throw new JspException("no parent UIComponentTag found");
+ }
+
+ if (!componentTag.getCreated())
+ {
+ return Tag.SKIP_BODY;
+ }
+
+ ActionSource holder = null;
+ UIComponent component = componentTag.getComponentInstance();
+ try
+ {
+ holder = (ActionSource) component;
+ } catch (ClassCastException e)
+ {
+ throw new JspException(
+ "Component " + ((UIComponent) holder).getId() + " is not instance of " + ActionSource.class.getName());
+ }
+ if (_type != null && _type.isLiteralText())
+ {
+ addClassicActionListener(holder,component);
+ }else{
+ addListener(holder, new DelegateActionListener(_type,_binding));
+ }
+
+ return Tag.SKIP_BODY;
+ }
+
+ protected void addClassicActionListener(ActionSource holder,UIComponent component) throws JspException
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ActionListener listener;
+ // type and/or binding must be specified
+ try
+ {
+ if (null != _binding)
+ {
+ try
+ {
+ listener = (ActionListener) _binding.getValue(facesContext.getELContext());
+ if (null != listener)
+ {
+ addListener(holder, listener);
+ // no need for further processing
+ return;
+ }
+ }
+ catch (ELException e)
+ {
+ throw new JspException("Exception while evaluating the binding attribute of Component "
+ + component.getId(), e);
+ }
+ }
+ if (null != _type)
+ {
+ String className;
+ if (_type.isLiteralText())
+ {
+ className = _type.getExpressionString();
+ } else
+ {
+ className = (String) _type.getValue(facesContext.getELContext());
+ }
+
+ listener = null;
+ //listener = (ActionListener) ClassUtils.newInstance(className);
+ if (null != _binding)
+ {
+ try
+ {
+ _binding.setValue(facesContext.getELContext(), listener);
+ } catch (ELException e)
+ {
+ throw new JspException("Exception while evaluating the binding attribute of Component "
+ + component.getId(), e);
+ }
+ }
+ addListener(holder, listener);
+ }
+ } catch (ClassCastException e)
+ {
+ throw new JspException(e);
+ }
+ }
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,177 @@
+/*
+ * 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.bindingCLV;
+
+import java.math.BigDecimal;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.event.ValueChangeListener;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class BindingCLVBean implements ActionListener, Validator, Converter, ValueChangeListener
+{
+
+ private BigDecimal bigdecimal;
+
+ private HtmlInputText input1;
+
+ //private ActionListener listener;
+
+ Log log = LogFactory.getLog(BindingCLVBean.class);
+
+ public void beforePhase(PhaseEvent phaseEvent)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ facesContext.addMessage(null, new FacesMessage(
+ "This is the message for phase before "
+ + phaseEvent.getPhaseId().toString()+" "+this));
+ log.info("This is the message for phase before "
+ + phaseEvent.getPhaseId().toString() + " : "+this);
+ /*
+ facesContext.addMessage(null, new FacesMessage("Component:"
+ + this.getInput1() + " converter: "
+ + this.getInput1().getConverter()));
+ //facesContext.addMessage(null, new FacesMessage("Component:"+this.getInput2()));
+ facesContext.addMessage(null, new FacesMessage("Validator:"
+ + this.getValidatorBigdecimal()));
+ //facesContext.addMessage(null, new FacesMessage("Validator:"+this.getValidatorBigint()));
+ facesContext.addMessage(null, new FacesMessage("Converter:"
+ + this.getConverterBigdecimal()));
+ facesContext.addMessage(null, new FacesMessage("Bean: " + this));
+ //facesContext.addMessage(null, new FacesMessage("Converter:"+this.getConverterBigint()));
+ //facesContext.addMessage(null, new FacesMessage("ActionListener:"
+ // + this.getListener()));
+ log.info("This is the message for phase before "
+ + phaseEvent.getPhaseId().toString() + " : ");
+ */
+ }
+
+ public void afterPhase(PhaseEvent phaseEvent)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ facesContext.addMessage(null, new FacesMessage(
+ "This is the message for phase after "
+ + phaseEvent.getPhaseId().toString()+" "+this));
+ log.info("This is the message for phase after "
+ + phaseEvent.getPhaseId().toString() + " : "+" "+this);
+
+ /*
+ facesContext.addMessage(null, new FacesMessage("Component:"
+ + this.getInput1() + " converter: "
+ + this.getInput1().getConverter()));
+ //facesContext.addMessage(null, new FacesMessage("Component:"+this.getInput2()));
+ facesContext.addMessage(null, new FacesMessage("Validator:"
+ + this.getValidatorBigdecimal()));
+ //facesContext.addMessage(null, new FacesMessage("Validator:"+this.getValidatorBigint()));
+ facesContext.addMessage(null, new FacesMessage("Converter:"
+ + this.getConverterBigdecimal()));
+ facesContext.addMessage(null, new FacesMessage("Bean: " + this));
+ //facesContext.addMessage(null, new FacesMessage("Converter:"+this.getConverterBigint()));
+ //facesContext.addMessage(null, new FacesMessage("ActionListener:"
+ // + this.getListener()));
+ */
+ }
+
+ public BigDecimal getBigdecimal()
+ {
+ return bigdecimal;
+ }
+
+ public void setBigdecimal(BigDecimal bigdecimal)
+ {
+ this.bigdecimal = bigdecimal;
+ }
+
+ public String update()
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ return "update";
+ }
+
+ public HtmlInputText getInput1()
+ {
+ return input1;
+ }
+
+ public void setInput1(HtmlInputText input1)
+ {
+ this.input1 = input1;
+ }
+
+ public void processAction(ActionEvent arg0) throws AbortProcessingException
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ facesContext.addMessage(null, new FacesMessage("Action : " + this));
+ }
+
+ public void validate(FacesContext arg0, UIComponent arg1, Object arg2)
+ throws ValidatorException
+ {
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ facesContext.addMessage(null, new FacesMessage("Validate : " + this));
+ }
+
+ public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2)
+ throws ConverterException
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ facesContext.addMessage(null, new FacesMessage("Converter getAsObject : " + this));
+
+ return FacesContext.getCurrentInstance().getApplication()
+ .createConverter("javax.faces.BigDecimal").getAsObject(arg0,
+ arg1, arg2);
+ }
+
+ public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2)
+ throws ConverterException
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ facesContext.addMessage(null, new FacesMessage("Converter getAsString : " + this));
+
+ return FacesContext.getCurrentInstance().getApplication()
+ .createConverter("javax.faces.BigDecimal").getAsString(arg0,
+ arg1, arg2);
+ }
+
+ public void processValueChange(ValueChangeEvent arg0)
+ throws AbortProcessingException
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ facesContext.addMessage(null, new FacesMessage("ValueChangeListener : " + this));
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,150 @@
+/*
+ * 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.bindingCLV;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.webapp.ConverterELTag;
+import javax.servlet.jsp.JspException;
+
+/**
+ * Implementation of ConverterELTag
+ *
+ * Implements the Tag class of f:converter
+ *
+ */
+public class ConverterImplTag extends ConverterELTag
+{
+
+ private static final long serialVersionUID = -4506829108081L;
+ private ValueExpression _converterId;
+ private ValueExpression _binding;
+ private String _converterIdString = null;
+
+ public ConverterImplTag()
+ {
+ super();
+ }
+
+ public void setConverterId(ValueExpression converterId)
+ {
+ _converterId = converterId;
+ }
+
+ public void setBinding(ValueExpression binding)
+ {
+ _binding = binding;
+ }
+
+ /**
+ * Use this method to specify the converterId programmatically.
+ *
+ * @param converterIdString
+ */
+ public void setConverterIdString(String converterIdString)
+ {
+ _converterIdString = converterIdString;
+ }
+
+ public void release()
+ {
+ super.release();
+ _converterId = null;
+ _binding = null;
+ _converterIdString = null;
+ }
+
+ protected Converter createConverter() throws JspException
+ {
+ if (_converterId != null && _converterId.isLiteralText())
+ {
+ this.createClassicConverter();
+ }
+ if (_converterIdString != null){
+ this.createClassicConverter();
+ }
+
+ return new DelegateConverter(_converterId, _binding,
+ _converterIdString);
+ }
+
+ protected Converter createClassicConverter() throws JspException
+ {
+ Converter converter = null;
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ELContext elContext = facesContext.getELContext();
+
+ // try to create the converter from the binding expression first, and then from
+ // the converterId
+ if (_binding != null)
+ {
+ try
+ {
+ converter = (Converter) _binding.getValue(elContext);
+
+ if (converter != null)
+ {
+ return converter;
+ }
+ }
+ catch (Exception e)
+ {
+ throw new JspException(
+ "Exception creating converter using binding", e);
+ }
+ }
+
+ if ((_converterId != null) || (_converterIdString != null))
+ {
+ try
+ {
+ if (null != _converterIdString)
+ {
+ converter = facesContext.getApplication().createConverter(
+ _converterIdString);
+ }
+ else
+ {
+ String converterId = (String) _converterId
+ .getValue(elContext);
+ converter = facesContext.getApplication().createConverter(
+ converterId);
+ }
+
+ // with binding no converter was created, set its value with the converter
+ // created using the converterId
+ if (converter != null && _binding != null)
+ {
+ _binding.setValue(elContext, converter);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new JspException(
+ "Exception creating converter with converterId: "
+ + _converterId, e);
+ }
+ }
+
+ return converter;
+ }
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,160 @@
+/*
+ * 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.bindingCLV;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+
+
+/**
+ * This class is used in conjunction with ActionListenerImplTag.
+ *
+ * When a tag like this is in a jsp page:
+ *
+ * <f:actionListener binding="#{mybean}"/>
+ *
+ * or
+ *
+ * <f:actionListener type="#{'anyid'}" binding="#{mybean}"/>
+ *
+ * The value of mybean could be already on the context, so this
+ * converter avoid creating a new variable and use the previous one.
+ *
+ */
+public class DelegateActionListener implements ActionListener, StateHolder
+{
+
+ private ValueExpression _type;
+ private ValueExpression _binding;
+
+ public DelegateActionListener()
+ {
+ }
+
+ public DelegateActionListener(ValueExpression type, ValueExpression binding)
+ {
+ super();
+ _type = type;
+ _binding = binding;
+ }
+
+ public boolean isTransient()
+ {
+ return false;
+ }
+
+ public void restoreState(FacesContext facesContext, Object state)
+ {
+ Object[] values = (Object[]) state;
+ _type = (ValueExpression) values[0];
+ _binding = (ValueExpression) values[1];
+ }
+
+ public Object saveState(FacesContext facesContext)
+ {
+ Object[] values = new Object[2];
+ values[0] = _type;
+ values[1] = _binding;
+ return values;
+ }
+
+ public void setTransient(boolean arg0)
+ {
+ // Do nothing
+ }
+
+ private ActionListener _getDelegate()
+ {
+ return _createActionListener();
+ }
+
+ private ActionListener _createActionListener()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ActionListener listener = null;
+ // type and/or binding must be specified
+ try
+ {
+ if (null != _binding)
+ {
+ try
+ {
+ listener = (ActionListener) _binding.getValue(facesContext
+ .getELContext());
+ if (null != listener)
+ {
+ return listener;
+ }
+ }
+ catch (ELException e)
+ {
+ //throw new JspException("Exception while evaluating the binding attribute of Component "
+ // + component.getId(), e);
+ }
+ }
+ if (null != _type)
+ {
+ String className;
+ if (_type.isLiteralText())
+ {
+ className = _type.getExpressionString();
+ }
+ else
+ {
+ className = (String) _type.getValue(facesContext
+ .getELContext());
+ }
+ listener = null;
+ //listener = (ActionListener) ClassUtils.newInstance(className);
+ if (null != _binding)
+ {
+ try
+ {
+ _binding
+ .setValue(facesContext.getELContext(), listener);
+ }
+ catch (ELException e)
+ {
+ //throw new JspException("Exception while evaluating the binding attribute of Component "
+ // + component.getId(), e);
+ }
+ }
+ return listener;
+ }
+ }
+ catch (ClassCastException e)
+ {
+ throw new FacesException(e);
+ }
+ return listener;
+ }
+
+ public void processAction(ActionEvent event)
+ throws AbortProcessingException
+ {
+ _getDelegate().processAction(event);
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,162 @@
+/*
+ * 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.bindingCLV;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+/**
+ * This class is used in conjunction with ConverterImplTag.
+ *
+ * When a tag like this is in a jsp page:
+ *
+ * <f:converter binding="#{mybean}"/>
+ *
+ * or
+ *
+ * <f:converter converterId="#{'anyid'}" binding="#{mybean}"/>
+ *
+ * The value of mybean could be already on the context, so this
+ * converter avoid creating a new variable and use the previous one.
+ *
+ */
+public class DelegateConverter implements Converter, StateHolder
+{
+
+ private ValueExpression _converterId;
+ private ValueExpression _binding;
+ private String _converterIdString = null;
+
+ public DelegateConverter(){
+
+ }
+
+ public DelegateConverter(ValueExpression id, ValueExpression binding, String converterIdString)
+ {
+ super();
+ _converterId = id;
+ _binding = binding;
+ _converterIdString = converterIdString;
+ }
+
+ public boolean isTransient()
+ {
+ return false;
+ }
+
+ public void restoreState(FacesContext facesContext, Object state)
+ {
+ Object[] values = (Object[]) state;
+ _converterId = (ValueExpression) values[0];
+ _binding = (ValueExpression) values[1];
+ _converterIdString = (String) values[2];
+ }
+
+ public Object saveState(FacesContext facesContext)
+ {
+ Object[] values = new Object[3];
+ values[0] = _converterId;
+ values[1] = _binding;
+ values[2] = _converterIdString;
+ return values;
+ }
+
+ public void setTransient(boolean arg0)
+ {
+ // Do nothing
+ }
+
+ public Object getAsObject(FacesContext facesContext, UIComponent component,
+ String value)
+ {
+ return _getDelegate().getAsObject(facesContext, component, value);
+ }
+
+ public String getAsString(FacesContext facesContext, UIComponent component,
+ Object value)
+ {
+ return _getDelegate().getAsString(facesContext, component, value);
+ }
+
+ private Converter _getDelegate()
+ {
+ return _createConverter();
+ }
+
+ private Converter _createConverter()
+ {
+ Converter converter = null;
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ELContext elContext = facesContext.getELContext();
+
+ // try to create the converter from the binding expression first, and then from
+ // the converterId
+ if (_binding != null)
+ {
+ try
+ {
+ converter = (Converter) _binding.getValue(elContext);
+
+ if (converter != null)
+ {
+ return converter;
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ConverterException("Exception creating converter using binding", e);
+ }
+ }
+
+ if ((_converterId != null) || (_converterIdString != null))
+ {
+ try
+ {
+ if (null != _converterIdString)
+ {
+ converter = facesContext.getApplication().createConverter(_converterIdString);
+ } else
+ {
+ String converterId = (String) _converterId.getValue(elContext);
+ converter = facesContext.getApplication().createConverter(converterId);
+ }
+
+ // with binding no converter was created, set its value with the converter
+ // created using the converterId
+ if (converter != null && _binding != null)
+ {
+ _binding.setValue(elContext, converter);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ConverterException("Exception creating converter with converterId: " + _converterId, e);
+ }
+ }
+
+ return converter;
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,152 @@
+/*
+ * 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.bindingCLV;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import javax.servlet.jsp.JspException;
+
+/**
+ * This class is used in conjunction with ValidatorImplTag.
+ *
+ * When a tag like this is in a jsp page:
+ *
+ * <f:validator binding="#{mybean}"/>
+ *
+ * or
+ *
+ * <f:validator validatorId="#{'anyid'}" binding="#{mybean}"/>
+ *
+ * The value of mybean could be already on the context, so this
+ * converter avoid creating a new variable and use the previous one.
+ *
+ */
+public class DelegateValidator implements Validator, StateHolder
+{
+
+ private ValueExpression _validatorId;
+ private ValueExpression _binding;
+ private String _validatorIdString = null;
+
+ public DelegateValidator(){
+
+ }
+
+ public DelegateValidator(ValueExpression id, ValueExpression binding, String converterIdString)
+ {
+ super();
+ _validatorId = id;
+ _binding = binding;
+ _validatorIdString = converterIdString;
+ }
+
+ public boolean isTransient()
+ {
+ return false;
+ }
+
+ public void restoreState(FacesContext facesContext, Object state)
+ {
+ Object[] values = (Object[]) state;
+ _validatorId = (ValueExpression) values[0];
+ _binding = (ValueExpression) values[1];
+ _validatorIdString = (String) values[2];
+ }
+
+ public Object saveState(FacesContext facesContext)
+ {
+ Object[] values = new Object[3];
+ values[0] = _validatorId;
+ values[1] = _binding;
+ values[2] = _validatorIdString;
+ return values;
+ }
+
+ public void setTransient(boolean arg0)
+ {
+ // Do nothing
+ }
+
+ private Validator _getDelegate()
+ {
+ return _createValidator();
+ }
+
+ private Validator _createValidator()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ELContext elContext = facesContext.getELContext();
+ if (null != _binding)
+ {
+ Object validator;
+ try
+ {
+ validator = _binding.getValue(elContext);
+ } catch (Exception e)
+ {
+ throw new ValidatorException(new FacesMessage("Error while creating the Validator"), e);
+ }
+ if (validator instanceof Validator)
+ {
+ return (Validator) validator;
+ }
+ }
+ Application application = facesContext.getApplication();
+ Validator validator = null;
+ try
+ {
+ // first check if an ValidatorId was set by a method
+ if (null != _validatorIdString)
+ {
+ validator = application.createValidator(_validatorIdString);
+ } else if (null != _validatorId)
+ {
+ String validatorId = (String) _validatorId.getValue(elContext);
+ validator = application.createValidator(validatorId);
+ }
+ } catch (Exception e)
+ {
+ throw new ValidatorException(new FacesMessage("Error while creating the Validator"), e);
+ }
+
+ if (null != validator)
+ {
+ if (null != _binding)
+ {
+ _binding.setValue(elContext, validator);
+ }
+ return validator;
+ }
+ throw new ValidatorException(new FacesMessage("validatorId and/or binding must be specified"));
+ }
+
+ public void validate(FacesContext facesContext, UIComponent component, Object value)
+ throws ValidatorException
+ {
+ _getDelegate().validate(facesContext, component, value);
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,32 @@
+/*
+ * 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.bindingCLV;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+
+public class DummyActionListener implements ActionListener {
+
+ public void processAction(ActionEvent arg0) throws AbortProcessingException {
+ //Do nothing
+
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.bindingCLV;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class DummyValidator implements Validator {
+
+ Log log = LogFactory.getLog(DummyValidator.class);
+
+ public DummyValidator(){
+ log.info("DummyValidator Constructor called");
+ Thread.dumpStack();
+ }
+
+ public void validate(FacesContext arg0, UIComponent arg1, Object arg2)
+ throws ValidatorException {
+ // Do nothing
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ facesContext.addMessage(null, new FacesMessage("Validate : " + this));
+
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,129 @@
+/*
+* Copyright 2004-2006 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.myfaces.bindingCLV;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.application.Application;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.webapp.ValidatorELTag;
+import javax.servlet.jsp.JspException;
+
+/**
+ * Basic Validator implementation.
+ *
+ */
+public class ValidatorImplTag
+ extends ValidatorELTag
+{
+ private ValueExpression _validatorId;
+ private ValueExpression _binding;
+ private String _validatorIdString = null;
+
+ public void setValidatorId(ValueExpression validatorId)
+ {
+ _validatorId = validatorId;
+ }
+
+ public void setBinding(ValueExpression binding)
+ {
+ _binding = binding;
+ }
+
+ /**
+ * Use this method to specify the validatorId programmatically.
+ *
+ * @param validatorIdString
+ */
+ public void setValidatorIdString(String validatorIdString)
+ {
+ _validatorIdString = validatorIdString;
+ }
+
+ public void release()
+ {
+ super.release();
+ _validatorId = null;
+ _binding = null;
+ _validatorIdString = null;
+ }
+
+ protected Validator createValidator() throws javax.servlet.jsp.JspException
+ {
+ Thread.dumpStack();
+ if (_validatorIdString != null)
+ {
+ return this.createClassicValidator();
+ }
+ if (_validatorId != null && _validatorId.isLiteralText())
+ {
+ return this.createClassicValidator();
+ }
+
+ return new DelegateValidator(_validatorId, _binding,
+ _validatorIdString);
+ }
+
+ protected Validator createClassicValidator() throws javax.servlet.jsp.JspException
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ELContext elContext = facesContext.getELContext();
+ if (null != _binding)
+ {
+ Object validator;
+ try
+ {
+ validator = _binding.getValue(elContext);
+ } catch (Exception e)
+ {
+ throw new JspException("Error while creating the Validator", e);
+ }
+ if (validator instanceof Validator)
+ {
+ return (Validator) validator;
+ }
+ }
+ Application application = facesContext.getApplication();
+ Validator validator = null;
+ try
+ {
+ // first check if an ValidatorId was set by a method
+ if (null != _validatorIdString)
+ {
+ validator = application.createValidator(_validatorIdString);
+ } else if (null != _validatorId)
+ {
+ String validatorId = (String) _validatorId.getValue(elContext);
+ validator = application.createValidator(validatorId);
+ }
+ } catch (Exception e)
+ {
+ throw new JspException("Error while creating the Validator", e);
+ }
+
+ if (null != validator)
+ {
+ if (null != _binding)
+ {
+ _binding.setValue(elContext, validator);
+ }
+ return validator;
+ }
+ throw new JspException("validatorId and/or binding must be specified");
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/blank/HelloWorldBacking.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/blank/HelloWorldBacking.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/blank/HelloWorldBacking.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/blank/HelloWorldBacking.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,114 @@
+/*
+ * 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.blank;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.faces.event.ActionEvent;
+import javax.faces.model.SelectItem;
+import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * A typical simple backing bean, that is backed to <code>helloworld.jsp</code>
+ *
+ * @author <a href="mailto:matzew@apache.org">Matthias Weßendorf</a>
+ */
+public class HelloWorldBacking {
+
+ private static Log log = LogFactory.getLog(HelloWorldBacking.class);
+ //properties
+ private String name;
+ private String greeting;
+ @Resource(name="testDouble")
+ private Double testDouble;
+
+ private List<String> numbers = Arrays.asList(new String[] {"One", "Two", "Three"});
+ private List<SelectItem> numbersToSelect;
+ /**
+ * default empty constructor
+ */
+ public HelloWorldBacking(){
+ greeting = "Hello";
+
+ numbersToSelect = new ArrayList<SelectItem>();
+ for (String strNum : numbers) {
+ numbersToSelect.add(new SelectItem(strNum));
+ }
+ }
+
+ @PostConstruct()
+ public void postConstruct() {
+ log.error("PostConstruct");
+ log.error("Test Double " + testDouble);
+ }
+
+ //-------------------getter & setter
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getGreeting()
+ {
+ return greeting;
+ }
+
+ public void setGreeting(String greeting)
+ {
+ this.greeting = greeting;
+ }
+
+ public List<String> getNumbers()
+ {
+ return numbers;
+ }
+
+ public void setNumbers(List<String> numbers)
+ {
+ this.numbers = numbers;
+ }
+
+ /**
+ * Method that is backed to a submit button of a form.
+ */
+ public String send(){
+ //do real logic
+ return ("success");
+ }
+
+ public void updateGreeting(ActionEvent evt)
+ {
+ greeting = "Bye!";
+ }
+
+ public List<SelectItem> getNumbersToSelect() {
+ return numbersToSelect;
+ }
+
+ public void setNumbersToSelect(List<SelectItem> numbersToSelect) {
+ this.numbersToSelect = numbersToSelect;
+ }
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/blank/NumberBean.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/blank/NumberBean.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/blank/NumberBean.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/blank/NumberBean.java Thu Jan 28 02:03:43 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.blank;
+
+/**
+ * TODO comment this
+ *
+ * @author Bruno Aranda (baranda@ebi.ac.uk)
+ * @version $Id$
+ */
+public class NumberBean
+{
+ Integer number = null;
+
+ public NumberBean() {
+ number = 0;
+ }
+
+ public Integer getNumber()
+ {
+ System.out.println("Get number: "+ number);
+ return number;
+ }
+
+ public void setNumber(Integer number)
+ {
+ this.number = number;
+ }
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,39 @@
+/*
+ * 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.convertDateTime;
+
+import java.util.Calendar;
+import java.util.Date;
+
+public class DateTimeBean
+{
+
+ private Date startDate = Calendar.getInstance().getTime();
+
+ public Date getStartDate()
+ {
+ return startDate;
+ }
+
+ public void setStartDate(Date startDate)
+ {
+ this.startDate = startDate;
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,103 @@
+/*
+ * 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.convertbig;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.validator.DoubleRangeValidator;
+import javax.faces.validator.LongRangeValidator;
+
+public class ConvertBigBean {
+
+ private BigInteger bigint;
+
+ private BigDecimal bigdecimal;
+
+ private Converter converterBigint;
+
+ private Converter converterBigdecimal;
+
+ private LongRangeValidator validatorBigint;
+
+ private DoubleRangeValidator validatorBigdecimal;
+
+ public BigInteger getBigint() {
+ return bigint;
+ }
+
+ public void setBigint(BigInteger bigint) {
+ this.bigint = bigint;
+ }
+
+ public BigDecimal getBigdecimal() {
+ return bigdecimal;
+ }
+
+ public void setBigdecimal(BigDecimal bigdecimal) {
+ this.bigdecimal = bigdecimal;
+ }
+
+ public Converter getConverterBigint() {
+ return converterBigint;
+ }
+
+ public void setConverterBigint(Converter converterBigint) {
+ this.converterBigint = converterBigint;
+ }
+
+ public Converter getConverterBigdecimal() {
+ return converterBigdecimal;
+ }
+
+ public void setConverterBigdecimal(Converter converterBigdecimal) {
+ this.converterBigdecimal = converterBigdecimal;
+ }
+
+ public LongRangeValidator getValidatorBigint() {
+ return validatorBigint;
+ }
+
+ public void setValidatorBigint(LongRangeValidator validatorBigint) {
+ this.validatorBigint = validatorBigint;
+ }
+
+ public DoubleRangeValidator getValidatorBigdecimal() {
+ return validatorBigdecimal;
+ }
+
+ public void setValidatorBigdecimal(DoubleRangeValidator validatorBigdecimal) {
+ this.validatorBigdecimal = validatorBigdecimal;
+ }
+
+ public String update(){
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ context.addMessage(null, new FacesMessage("Validator:"+this.getValidatorBigdecimal()));
+ context.addMessage(null, new FacesMessage("Validator:"+this.getValidatorBigint()));
+ context.addMessage(null, new FacesMessage("Converter:"+this.getConverterBigdecimal()));
+ context.addMessage(null, new FacesMessage("Converter:"+this.getConverterBigint()));
+
+ return "update";
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.disabled;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.model.SelectItem;
+
+public class DisabledBean
+{
+
+ private Boolean disabled = Boolean.TRUE;
+
+ public Boolean getDisabled()
+ {
+ return disabled;
+ }
+
+ public void setDisabled(Boolean disabled)
+ {
+ this.disabled = disabled;
+ }
+
+ public List<SelectItem> getList(){
+ List list = new ArrayList();
+ list.add(new SelectItem(Boolean.TRUE,"True"));
+ list.add(new SelectItem(Boolean.FALSE,"False"));
+ return list;
+ }
+}
Added: 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=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,38 @@
+/*
+ * 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.enumtest;
+
+public class EnumBean
+{
+
+ public enum Actions{ step1, step2, step3 }
+
+ public Object step1(){
+ return Actions.step1;
+ }
+
+ public Object step2(){
+ return Actions.step2;
+ }
+
+ public Object step3(){
+ return Actions.step3;
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,55 @@
+/*
+ * 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.examples.example1;
+
+import javax.el.ELResolver;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+
+/**
+ * DOCUMENT ME!
+ * @author Manfred Geiler
+ * @version $Revision: 692962 $ $Date: 2008-09-08 02:10:51 +0200 (Mo, 08 Sep 2008) $
+ */
+public class CalcActionListener
+ implements ActionListener
+{
+ public void processAction(ActionEvent event) throws AbortProcessingException
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIComponent component = event.getComponent();
+
+ ELResolver vr = facesContext.getELContext().getELResolver();
+ CalcForm form = (CalcForm)vr.getValue(
+ facesContext.getELContext() , null, "calcForm");
+ if (component.getId().equals("addButton") ||
+ component.getId().equals("href1"))
+ {
+ form.add();
+ }
+ else
+ {
+ form.subtract();
+ }
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,151 @@
+/*
+ * 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.examples.example1;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * DOCUMENT ME!
+ *
+ * @author Manfred Geiler
+ * @version $Revision: 692962 $ $Date: 2006-11-08 14:46:34 -0500 (Wed, 08 Nov
+ * 2006) $
+ */
+public class CalcForm implements Serializable {
+ /**
+ * serial id for serialisation versioning
+ */
+ private static final long serialVersionUID = 1L;
+ private Long number1 = new Long(0);
+ private Long number2 = new Long(0);
+ private Long result = new Long(0);
+
+ Log log = LogFactory.getLog(CalcForm.class);
+
+ public String getCustomMessage() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ // ELResolver vr = facesContext.getELContext().getELResolver();
+
+ // ResourceBundle s1 = (ResourceBundle)
+ // vr.getValue(facesContext.getELContext(),
+ // FacesContext.getCurrentInstance().getViewRoot(), "example_messages");
+
+ // VariableResolver vr =
+ // facesContext.getApplication().getVariableResolver();
+ // ResourceBundle s1 = (ResourceBundle) vr.resolveVariable(facesContext,
+ // "example_messages");
+
+ // return s1.getString("sample1_number");
+ // return (String) vr.resolveVariable(facesContext,
+ // "example_messages['sample1_number']");
+ return "Label loaded from bean";
+ }
+
+ public void add() {
+ result = number1 + (number2);
+ }
+
+ public void subtract() {
+ result = number1 - (number2);
+ }
+
+ public Long getNumber1() {
+ return number1;
+ }
+
+ public void setNumber1(Long number1) {
+ this.number1 = number1;
+ }
+
+ public Long getNumber2() {
+ return number2;
+ }
+
+ public void setNumber2(Long number2) {
+ this.number2 = number2;
+ }
+
+ public Long getResult() {
+ return result;
+ }
+
+ public void setResult(Long result) {
+ this.result = result;
+ }
+
+ public void beforePhase(PhaseEvent phaseEvent) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ log.info("phase before " + phaseEvent.getPhaseId().toString() + " : ");
+ // System.out.println("This is the message for phase before
+ // "+phaseEvent.getPhaseId().toString()+" : ");
+ for (Iterator<String> it1 = facesContext.getClientIdsWithMessages(); it1
+ .hasNext();) {
+ String clientId = it1.next();
+ log.info("ClientId: " + clientId);
+ for (Iterator<FacesMessage> it = facesContext.getMessages(clientId); it
+ .hasNext();) {
+ FacesMessage msg = it.next();
+ log.info("MESSAGE: [" + msg.getSummary() + "] ["
+ + msg.getDetail() + "]");
+ // System.out.println("MESSAGE:"+msg.getSummary() + " "+
+ // msg.getDetail() );
+ }
+
+ }
+ //facesContext.addMessage("form1:number1", new FacesMessage(
+ // "{0}: Validation Error: Value is prueba."));
+ }
+
+ public void afterPhase(PhaseEvent phaseEvent) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ log.info("phase after " + phaseEvent.getPhaseId().toString() + " : ");
+ // System.out.println("This is the message for phase after
+ // "+phaseEvent.getPhaseId().toString()+" : ");
+ for (Iterator<String> it1 = facesContext.getClientIdsWithMessages(); it1
+ .hasNext();) {
+ String clientId = it1.next();
+ log.info("ClientId: " + clientId);
+ for (Iterator<FacesMessage> it = facesContext.getMessages(clientId); it
+ .hasNext();) {
+ FacesMessage msg = it.next();
+ log.info("MESSAGE: [" + msg.getSummary() + "] ["
+ + msg.getDetail() + "]");
+ // System.out.println("MESSAGE:"+msg.getSummary() + " "+
+ // msg.getDetail() );
+ }
+
+ }
+ }
+
+ public String getActionClass(){
+ return "org.apache.myfaces.examples.example1.CalcActionListener";
+ }
+
+}
Added: myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java
URL: http://svn.apache.org/viewvc/myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java?rev=903939&view=auto
==============================================================================
--- myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java (added)
+++ myfaces/current20/test-webapp/webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java Thu Jan 28 02:03:43 2010
@@ -0,0 +1,155 @@
+/*
+ * 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.examples.example1;
+
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.LengthValidator;
+import javax.faces.validator.LongRangeValidator;
+import javax.faces.validator.Validator;
+
+/**
+ * DOCUMENT ME!
+ * @author Manfred Geiler
+ * @version $Revision: 692962 $ $Date: 2008-09-08 02:10:51 +0200 (Mo, 08 Sep 2008) $
+ */
+public class ValidationController
+{
+ public String enableValidation()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ UIInput number1 = (UIInput)facesContext.getViewRoot().findComponent("form1:number1");
+ Validator[] validators = number1.getValidators();
+ if (validators == null || validators.length == 0)
+ {
+ number1.addValidator(new LongRangeValidator(10, 1));
+ }
+
+ UIInput number2 = (UIInput)facesContext.getViewRoot().findComponent("form1:number2");
+ validators = number2.getValidators();
+ if (validators == null || validators.length == 0)
+ {
+ number2.addValidator(new LongRangeValidator(50, 20));
+ }
+
+ UIInput text = (UIInput)facesContext.getViewRoot().findComponent("form2:text");
+ validators = text.getValidators();
+ if (validators == null || validators.length == 0)
+ {
+ text.addValidator(new LengthValidator(7, 3));
+ }
+
+ return "ok";
+ }
+
+ public String disableValidation()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ UIInput number1 = (UIInput)facesContext.getViewRoot().findComponent("form1:number1");
+ Validator[] validators = number1.getValidators();
+ if (validators != null)
+ {
+ for (int i = 0; i < validators.length; i++)
+ {
+ Validator validator = validators[i];
+ number1.removeValidator(validator);
+ }
+ }
+
+ UIInput number2 = (UIInput)facesContext.getViewRoot().findComponent("form1:number2");
+ validators = number2.getValidators();
+ if (validators != null)
+ {
+ for (int i = 0; i < validators.length; i++)
+ {
+ Validator validator = validators[i];
+ number2.removeValidator(validator);
+ }
+ }
+
+ UIInput text = (UIInput)facesContext.getViewRoot().findComponent("form2:text");
+ validators = text.getValidators();
+ if (validators != null)
+ {
+ for (int i = 0; i < validators.length; i++)
+ {
+ Validator validator = validators[i];
+ text.removeValidator(validator);
+ }
+ }
+
+ return "ok";
+ }
+
+
+
+ public String getNumber1ValidationLabel()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIInput number1 = (UIInput)facesContext.getViewRoot().findComponent("form1:number1");
+ Validator[] validators = number1.getValidators();
+ if (validators != null && validators.length > 0)
+ {
+ long min = ((LongRangeValidator)validators[0]).getMinimum();
+ long max = ((LongRangeValidator)validators[0]).getMaximum();
+ return " (" + min + "-" + max + ")";
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ public String getNumber2ValidationLabel()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIInput number1 = (UIInput)facesContext.getViewRoot().findComponent("form1:number2");
+ Validator[] validators = number1.getValidators();
+ if (validators != null && validators.length > 0)
+ {
+ long min = ((LongRangeValidator)validators[0]).getMinimum();
+ long max = ((LongRangeValidator)validators[0]).getMaximum();
+ return " (" + min + "-" + max + ")";
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ public String getTextValidationLabel()
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIInput number1 = (UIInput)facesContext.getViewRoot().findComponent("form2:text");
+ Validator[] validators = number1.getValidators();
+ if (validators != null && validators.length > 0)
+ {
+ long min = ((LengthValidator)validators[0]).getMinimum();
+ long max = ((LengthValidator)validators[0]).getMaximum();
+ return " (" + min + "-" + max + " chars)";
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+}