myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r991836 - in /myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp: TrinidadConverterELTag.java TrinidadValidatorELTag.java
Date Thu, 02 Sep 2010 07:54:50 GMT
Author: matzew
Date: Thu Sep  2 07:54:49 2010
New Revision: 991836

URL: http://svn.apache.org/viewvc?rev=991836&view=rev
Log:
TRINIDAD-1898 - Stop using the TagSupport convenience class

adding Converter/Validator EL Tags for Trinidad that don't extend the standard TagSupport

Added:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TrinidadConverterELTag.java
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TrinidadValidatorELTag.java

Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TrinidadConverterELTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TrinidadConverterELTag.java?rev=991836&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TrinidadConverterELTag.java
(added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TrinidadConverterELTag.java
Thu Sep  2 07:54:49 2010
@@ -0,0 +1,70 @@
+/*
+ * 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.trinidad.webapp;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.ValueHolder;
+import javax.faces.convert.Converter;
+import javax.faces.webapp.UIComponentClassicTagBase;
+import javax.faces.webapp.UIComponentELTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.Tag;
+
+/**
+ * This is the Trinidad version of the JSF <code>ConverterELTag</code> class.
+ * The main difference is that this class is <b>NOT</b> inheriting from 
+ * the standard <code>TagSupport</code> and therefore does not 
+ * implement <code>Serializable</code> interface.
+ * 
+ * @author Apache MyFaces team
+ */
+public abstract class TrinidadConverterELTag extends TrinidadTagSupport
+{
+    @Override
+    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;
+        }
+
+        UIComponent component = componentTag.getComponentInstance();
+        if (component == null)
+        {
+            throw new JspException("parent UIComponentTag has no UIComponent");
+        }
+        if (!(component instanceof ValueHolder))
+        {
+            throw new JspException("UIComponent is no ValueHolder");
+        }
+
+        Converter converter = createConverter();
+
+        ((ValueHolder)component).setConverter(converter);
+
+        return Tag.SKIP_BODY;
+    }
+
+    protected abstract Converter createConverter() throws JspException;
+}

Added: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TrinidadValidatorELTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TrinidadValidatorELTag.java?rev=991836&view=auto
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TrinidadValidatorELTag.java
(added)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/TrinidadValidatorELTag.java
Thu Sep  2 07:54:49 2010
@@ -0,0 +1,73 @@
+/*
+ * 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.trinidad.webapp;
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.validator.Validator;
+import javax.faces.webapp.UIComponentClassicTagBase;
+import javax.faces.webapp.UIComponentELTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.Tag;
+
+/**
+ * This is the Trinidad version of the JSF <code>ValidatorELTag</code> class.
+ * The main difference is that this class is <b>NOT</b> inheriting from 
+ * the standard <code>TagSupport</code> and therefore does not 
+ * implement <code>Serializable</code> interface.
+ * 
+ * @author Apache MyFaces team
+ */
+public abstract class TrinidadValidatorELTag extends TrinidadTagSupport
+{
+    @Override
+    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;
+        }
+
+        Validator validator = createValidator();
+
+        UIComponent component = componentTag.getComponentInstance();
+        if (component == null)
+        {
+            throw new JspException("parent UIComponentTag has no UIComponent");
+        }
+
+        if (!(component instanceof EditableValueHolder))
+        {
+            throw new JspException("UIComponent is no EditableValueHolder");
+        }
+        ((EditableValueHolder)component).addValidator(validator);
+
+        return Tag.SKIP_BODY;
+    }
+
+    protected abstract Validator createValidator() throws JspException;
+
+}



Mime
View raw message