You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/03/06 16:15:39 UTC
svn commit: r634292 - in /myfaces/orchestra/trunk/core/src/main:
java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/
resources/META-INF/
Author: skitching
Date: Thu Mar 6 07:15:37 2008
New Revision: 634292
URL: http://svn.apache.org/viewvc?rev=634292&view=rev
Log:
Add facelets support
Added:
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/ConverterTagHandler.java (with props)
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/package.html (with props)
myfaces/orchestra/trunk/core/src/main/resources/META-INF/orchestra.taglib.xml (with props)
Added: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/ConverterTagHandler.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/ConverterTagHandler.java?rev=634292&view=auto
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/ConverterTagHandler.java (added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/ConverterTagHandler.java Thu Mar 6 07:15:37 2008
@@ -0,0 +1,68 @@
+package org.apache.myfaces.orchestra.conversation.jsf.components.facelets;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.FaceletException;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+import org.apache.myfaces.orchestra.lib.jsf.SerializableConverter;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import java.io.IOException;
+
+public class ConverterTagHandler extends TagHandler
+{
+ private final TagAttribute beanName;
+ private final TagAttribute useWrapper;
+
+ public ConverterTagHandler(TagConfig config)
+ {
+ super(config);
+ beanName = getRequiredAttribute("beanName"); // NON-NLS
+ useWrapper = getAttribute("useWrapper"); // NON-NLS
+ }
+
+ public void apply(FaceletContext faceletContext, UIComponent parent) throws IOException, FacesException, FaceletException, ELException
+ {
+ if (parent.getParent() == null)
+ {
+ if (parent instanceof EditableValueHolder)
+ {
+ Converter converter = createConverter(beanName.getValue());
+
+ if (useWrapper == null || !"false".equals(useWrapper.getValue()) &&
+ !(converter instanceof SerializableConverter))
+ {
+ // Needed to check if it is already of the specified type in case the
+ // managed-bean framework has been configured to auto-wrap Converter
+ // instances already (eg via a Spring BeanPostProcessor or equivalent).
+ // This isn't the case, so wrap it now.
+ converter = new SerializableConverter(beanName.getValue(), converter);
+ }
+
+ ((EditableValueHolder) parent).setConverter(converter);
+ }
+ else
+ {
+ throw new FacesException("parent is not an EditableValueHolder");
+ }
+ }
+ }
+
+ /**
+ * Override this method in order to customise the bean instance.
+ */
+ protected static Converter createConverter(String beanName)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Application application = facesContext.getApplication();
+ Object converter = application.getVariableResolver().resolveVariable(facesContext, beanName);
+ return (Converter) converter;
+ }
+}
Propchange: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/ConverterTagHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/package.html
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/package.html?rev=634292&view=auto
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/package.html (added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/package.html Thu Mar 6 07:15:37 2008
@@ -0,0 +1,30 @@
+<!--
+
+ 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.
+
+-->
+<html>
+<body>
+<p>
+This package provides custom Facelet TagHandler classes for the orchestra tags
+which need custom implementations.
+</p>
+<p>
+In most cases, JSF components do not need custom TagHandlers; facelets just handles
+them directly (as long as they are declared in the facelets taglib file).
+</p>
+</body>
+</html>
Propchange: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/components/facelets/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/orchestra/trunk/core/src/main/resources/META-INF/orchestra.taglib.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/resources/META-INF/orchestra.taglib.xml?rev=634292&view=auto
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/resources/META-INF/orchestra.taglib.xml (added)
+++ myfaces/orchestra/trunk/core/src/main/resources/META-INF/orchestra.taglib.xml Thu Mar 6 07:15:37 2008
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!DOCTYPE facelet-taglib PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
+ "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
+
+<facelet-taglib>
+ <namespace>http://myfaces.apache.org/orchestra</namespace>
+
+ <tag>
+ <tag-name>separateConversationContext</tag-name>
+ <component>
+ <component-type>org.apache.myfaces.orchestra.SeparateConversationContext</component-type>
+ </component>
+ </tag>
+
+ <tag>
+ <tag-name>endConversation</tag-name>
+ <component>
+ <component-type>org.apache.myfaces.orchestra.EndConversation</component-type>
+ </component>
+ </tag>
+
+ <tag>
+ <tag-name>converter</tag-name>
+ <handler-class>com.ops.OPSJ.jsflib.facelets.OrchestraConverterHandler</handler-class>
+ </tag>
+</facelet-taglib>
\ No newline at end of file
Propchange: myfaces/orchestra/trunk/core/src/main/resources/META-INF/orchestra.taglib.xml
------------------------------------------------------------------------------
svn:eol-style = native