You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/09/08 02:10:54 UTC
svn commit: r692962 [1/5] - in /myfaces/current12/test-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/ src/ma...
Author: lu4242
Date: Sun Sep 7 17:10:51 2008
New Revision: 692962
URL: http://svn.apache.org/viewvc?rev=692962&view=rev
Log:
MYFACES-1327 Make example webapp with 1.2 features
Added:
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertDateTime/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertbig/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/disabled/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/enumtest/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/listexample/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/listexample/SimpleCity.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountry.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryList.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/invoke/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/invoke/InvokeOnComponentBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/jstl/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/jstl/ListBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/phaseuiroot/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/phaseuiroot/PhaseMethodsUIRootBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/postback/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/postback/PostbackBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/renderkit/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/renderkit/CustomRenderKit.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/selectItem/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/selectItem/SelectItemBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/selectItem/SelectItemEscapeBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/servlet/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/servlet/SourceCodeServlet.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/setprop/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/setprop/SetPropertyBean.java (with props)
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/test/
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/test/Bean.java (with props)
myfaces/current12/test-webapp/src/main/resources/org/
myfaces/current12/test-webapp/src/main/resources/org/apache/
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/build.properties (with props)
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties (with props)
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_ca.properties (with props)
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_de.properties (with props)
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_en.properties (with props)
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_es.properties (with props)
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_fr.properties (with props)
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_ja.properties (with props)
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_pt_BR.properties (with props)
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_ru.properties (with props)
myfaces/current12/test-webapp/src/main/resources/org/apache/myfaces/examples/resource/example_messages_zh.properties (with props)
myfaces/current12/test-webapp/src/main/webapp/WEB-INF/converter.tld (with props)
myfaces/current12/test-webapp/src/main/webapp/bindingCLV.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/bindingCLV2.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/bundleWithEL.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/column.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/comp.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/comp2.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/comp3.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/comp4.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/convertBig.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/convertBig2.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/convertDateTime.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/css/
myfaces/current12/test-webapp/src/main/webapp/css/basic.css (with props)
myfaces/current12/test-webapp/src/main/webapp/css/common.css (with props)
myfaces/current12/test-webapp/src/main/webapp/css/table.css (with props)
myfaces/current12/test-webapp/src/main/webapp/detectPostback.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/disabledLink.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/forEach.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/forEachInclude.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/forEachInclude2.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/forEachInclude3.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/forEachInclude4.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/forEachTest.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/hideShowRadio.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/home.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/imageCommand.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/images/
myfaces/current12/test-webapp/src/main/webapp/images/button.gif (with props)
myfaces/current12/test-webapp/src/main/webapp/inc/
myfaces/current12/test-webapp/src/main/webapp/inc/head.inc
myfaces/current12/test-webapp/src/main/webapp/inc/page_footer.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/includeTest.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/invokeOnComponent.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/labelattribute.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/layoutMessages.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/layoutPanelGroup.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/multipleRenderKit.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/nullSelectItem.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/onclick.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/page.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/pageScope.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/phaseMethodsUIRoot.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/prettyOutRB.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/selectOneManyEscape.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/setProperty.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/step1.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/step2.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/step3.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/test.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/test2.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/test3.jsp (with props)
myfaces/current12/test-webapp/src/main/webapp/verbatimRendered.jsp (with props)
Modified:
myfaces/current12/test-webapp/pom.xml
myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/blank/NumberBean.java
myfaces/current12/test-webapp/src/main/webapp/WEB-INF/examples-config.xml
myfaces/current12/test-webapp/src/main/webapp/WEB-INF/web.xml
myfaces/current12/test-webapp/src/main/webapp/bundleTest.jsp
myfaces/current12/test-webapp/src/main/webapp/helloWorld.jsp
myfaces/current12/test-webapp/src/main/webapp/index.jsp
myfaces/current12/test-webapp/src/main/webapp/labelTest.jsp
myfaces/current12/test-webapp/src/main/webapp/page2.jsp
Modified: myfaces/current12/test-webapp/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/pom.xml?rev=692962&r1=692961&r2=692962&view=diff
==============================================================================
--- myfaces/current12/test-webapp/pom.xml (original)
+++ myfaces/current12/test-webapp/pom.xml Sun Sep 7 17:10:51 2008
@@ -167,6 +167,20 @@
</dependency>-->
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId>
<scope>provided</scope>
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java Sun Sep 7 17:10:51 2008
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.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);
+ }
+ }
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ActionListenerImplTag.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java Sun Sep 7 17:10:51 2008
@@ -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));
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/BindingCLVBean.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java Sun Sep 7 17:10:51 2008
@@ -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;
+ }
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ConverterImplTag.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java Sun Sep 7 17:10:51 2008
@@ -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);
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateActionListener.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java Sun Sep 7 17:10:51 2008
@@ -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;
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateConverter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java Sun Sep 7 17:10:51 2008
@@ -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);
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DelegateValidator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java Sun Sep 7 17:10:51 2008
@@ -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
+
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyActionListener.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java Sun Sep 7 17:10:51 2008
@@ -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));
+
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/DummyValidator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java Sun Sep 7 17:10:51 2008
@@ -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");
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/bindingCLV/ValidatorImplTag.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/blank/NumberBean.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/blank/NumberBean.java?rev=692962&r1=692961&r2=692962&view=diff
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/blank/NumberBean.java (original)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/blank/NumberBean.java Sun Sep 7 17:10:51 2008
@@ -1,3 +1,21 @@
+/*
+ * 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;
/**
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java Sun Sep 7 17:10:51 2008
@@ -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;
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertDateTime/DateTimeBean.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java Sun Sep 7 17:10:51 2008
@@ -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";
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/convertbig/ConvertBigBean.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java Sun Sep 7 17:10:51 2008
@@ -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;
+ }
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/disabled/DisabledBean.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java Sun Sep 7 17:10:51 2008
@@ -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;
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/enumtest/EnumBean.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java Sun Sep 7 17:10:51 2008
@@ -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$ $Date$
+ */
+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();
+ }
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcActionListener.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java Sun Sep 7 17:10:51 2008
@@ -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$ $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";
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/CalcForm.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java?rev=692962&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java Sun Sep 7 17:10:51 2008
@@ -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$ $Date$
+ */
+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 "";
+ }
+ }
+
+}
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/examples/example1/ValidationController.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL