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 2009/08/17 01:17:42 UTC
svn commit: r804815 - in /myfaces/core/trunk/impl/src:
main/java/org/apache/myfaces/application/
main/java/org/apache/myfaces/view/facelets/
main/java/org/apache/myfaces/view/facelets/compiler/
main/java/org/apache/myfaces/view/facelets/impl/ main/java...
Author: lu4242
Date: Sun Aug 16 23:17:41 2009
New Revision: 804815
URL: http://svn.apache.org/viewvc?rev=804815&view=rev
Log:
MYFACES-2310 Implement Composite Component feature
Added:
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java (with props)
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java (with props)
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/SerializableAttributesTestCase.java (with props)
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testComposite/
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testComposite/simpleAttribute.xhtml
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testComposite/simpleComposite.xhtml
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testSimpleAttribute.xhtml
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testSimpleComposite.xhtml
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/AbstractFaceletContext.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompilationManager.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentResourceTagHandler.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeLibrary.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java?rev=804815&r1=804814&r2=804815&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java Sun Aug 16 23:17:41 2009
@@ -1077,7 +1077,7 @@
*/
if (component == null)
{
- createComponent(UINamingContainer.COMPONENT_TYPE);
+ component = createComponent(UINamingContainer.COMPONENT_TYPE);
}
}
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/AbstractFaceletContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/AbstractFaceletContext.java?rev=804815&r1=804814&r2=804815&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/AbstractFaceletContext.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/AbstractFaceletContext.java Sun Aug 16 23:17:41 2009
@@ -22,6 +22,7 @@
import javax.el.ELException;
import javax.faces.FacesException;
+import javax.faces.application.Resource;
import javax.faces.component.UIComponent;
import javax.faces.view.facelets.FaceletContext;
import javax.faces.view.facelets.FaceletException;
@@ -72,4 +73,22 @@
*/
public abstract boolean includeDefinition(UIComponent parent, String name)
throws IOException, FaceletException, FacesException, ELException;
+
+ /**
+ * Apply the facelet referenced by a url containing a composite component
+ * definition to the current UIComponent. In other words, apply the section
+ * composite:implementation in the facelet to the current component.
+ *
+ * We need to do this here because DefaultFacelet is the one who has and
+ * handle the current FaceletFactory instance.
+ *
+ * @param parent
+ * @param url
+ * @throws IOException
+ * @throws FaceletException
+ * @throws FacesException
+ * @throws ELException
+ */
+ public abstract void applyCompositeComponent(UIComponent parent, Resource resource)
+ throws IOException, FaceletException, FacesException, ELException;
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompilationManager.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompilationManager.java?rev=804815&r1=804814&r2=804815&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompilationManager.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompilationManager.java Sun Aug 16 23:17:41 2009
@@ -33,6 +33,9 @@
import org.apache.myfaces.view.facelets.tag.TagAttributesImpl;
import org.apache.myfaces.view.facelets.tag.TagDecorator;
import org.apache.myfaces.view.facelets.tag.TagLibrary;
+import org.apache.myfaces.view.facelets.tag.composite.CompositeLibrary;
+import org.apache.myfaces.view.facelets.tag.composite.ImplementationHandler;
+import org.apache.myfaces.view.facelets.tag.composite.InterfaceHandler;
import org.apache.myfaces.view.facelets.tag.ui.ComponentRefHandler;
import org.apache.myfaces.view.facelets.tag.ui.CompositionHandler;
import org.apache.myfaces.view.facelets.tag.ui.UILibrary;
@@ -65,6 +68,8 @@
private boolean finished;
private final String alias;
+
+ private CompilationUnit interfaceCompilationUnit;
public CompilationManager(String alias, Compiler compiler)
{
@@ -89,6 +94,8 @@
// our compilationunit stack
this.units = new Stack<CompilationUnit>();
this.units.push(new CompilationUnit());
+
+ this.interfaceCompilationUnit = null;
}
public void writeInstruction(String value)
@@ -217,6 +224,42 @@
{
this.units.push(new RemoveUnit());
}
+ else if (isCompositeComponentInterface(qname[0], qname[1]))
+ {
+ // Here we have two cases when we found a <composite:interface> tag:
+ //
+ // - If a page has a <composite:interface> tag and a <composite:implementation> tag.
+ // In this case, we need to trim all tags outside this two tags, otherwise these
+ // unwanted tags will be added when the composite component is applied.
+ // Unfortunately, this is the only point we can do it, because after the compiler,
+ // html tags are wrapped on facelets UIInstruction or UIText components as "list",
+ // losing the original structure required to trim.
+ //
+ // - If a page has a <composite:interface> tag and not a <composite:implementation> tag.
+ // In this case, it is not necessary to trim, because we use the facelet only to create
+ // metadata and the component tree created is not used (see
+ // ViewDeclarationLanguage.getComponentMetadata() ). On InterfaceHandler, instead
+ // there is some code that found the right component in the temporal tree to add the
+ // generated BeanInfo, which it is retrieved later.
+ //
+ log.fine("Composite Component Interface Found, saving unit");
+ interfaceCompilationUnit = new TagUnit(this.tagLibrary, qname[0], qname[1], t, this.nextTagId());
+ this.startUnit(interfaceCompilationUnit);
+ }
+ else if (isCompositeComponentImplementation(qname[0], qname[1]))
+ {
+ log.fine("Composite component Found, Popping Parent Tags");
+ this.units.clear();
+ NamespaceUnit nsUnit = this.namespaceManager.toNamespaceUnit(this.tagLibrary);
+ this.units.push(nsUnit);
+ if (interfaceCompilationUnit != null)
+ {
+ this.currentUnit().addChild(interfaceCompilationUnit);
+ interfaceCompilationUnit = null;
+ }
+ this.startUnit(new TrimmedTagUnit(this.tagLibrary, qname[0], qname[1], t, this.nextTagId()));
+ log.fine("New Namespace and TagUnit pushed");
+ }
else if (this.tagLibrary.containsTagHandler(qname[0], qname[1]))
{
this.startUnit(new TagUnit(this.tagLibrary, qname[0], qname[1], t, this.nextTagId()));
@@ -364,6 +407,16 @@
return UILibrary.Namespace.equals(ns)
&& (CompositionHandler.Name.equals(name) || ComponentRefHandler.Name.equals(name));
}
+
+ protected static boolean isCompositeComponentInterface(String ns, String name)
+ {
+ return CompositeLibrary.NAMESPACE.equals(ns) && InterfaceHandler.NAME.equals(name);
+ }
+
+ protected static boolean isCompositeComponentImplementation(String ns, String name)
+ {
+ return CompositeLibrary.NAMESPACE.equals(ns) && ImplementationHandler.NAME.equals(name);
+ }
private String[] determineQName(Tag tag)
{
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java?rev=804815&r1=804814&r2=804815&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFacelet.java Sun Aug 16 23:17:41 2009
@@ -37,6 +37,7 @@
import javax.el.ELException;
import javax.el.ExpressionFactory;
import javax.faces.FacesException;
+import javax.faces.application.Resource;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.view.facelets.FaceletContext;
@@ -46,6 +47,7 @@
import org.apache.myfaces.view.facelets.Facelet;
import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
+
/**
* Default Facelet implementation.
*
@@ -311,6 +313,17 @@
DefaultFacelet f = (DefaultFacelet) _factory.getFacelet(url);
f.include(ctx, parent);
}
+
+ public void applyCompositeComponent(DefaultFaceletContext ctx, UIComponent parent, Resource resource) throws IOException, FacesException,
+ FaceletException, ELException
+ {
+ // Here we are creating a facelet using the url provided by the resource.
+ // It works, but the Resource API provides getInputStream() for that. But the default
+ // implementation wraps everything that could contain ValueExpression and decode so
+ // we can't use it here.
+ DefaultFacelet f = (DefaultFacelet) _factory.getFacelet(resource.getURL());
+ f.apply(ctx.getFacesContext(), parent);
+ }
private static class ApplyToken implements Externalizable
{
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java?rev=804815&r1=804814&r2=804815&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java Sun Aug 16 23:17:41 2009
@@ -36,6 +36,7 @@
import javax.el.ValueExpression;
import javax.el.VariableMapper;
import javax.faces.FacesException;
+import javax.faces.application.Resource;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.view.facelets.FaceletContext;
@@ -434,4 +435,11 @@
{
_ctx.setPropertyResolved(resolved);
}
+
+ @Override
+ public void applyCompositeComponent(UIComponent parent, Resource resource)
+ throws IOException, FaceletException, FacesException, ELException
+ {
+ _facelet.applyCompositeComponent(this, parent, resource);
+ }
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentResourceTagHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentResourceTagHandler.java?rev=804815&r1=804814&r2=804815&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentResourceTagHandler.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentResourceTagHandler.java Sun Aug 16 23:17:41 2009
@@ -18,16 +18,29 @@
*/
package org.apache.myfaces.view.facelets.tag.composite;
+import java.io.IOException;
+
+import javax.el.VariableMapper;
import javax.faces.application.Resource;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIPanel;
import javax.faces.context.FacesContext;
+import javax.faces.view.ViewDeclarationLanguage;
import javax.faces.view.facelets.ComponentConfig;
import javax.faces.view.facelets.ComponentHandler;
import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRuleset;
+import org.apache.myfaces.view.facelets.AbstractFaceletContext;
+import org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage;
+import org.apache.myfaces.view.facelets.el.VariableMapperWrapper;
import org.apache.myfaces.view.facelets.tag.jsf.ComponentBuilderHandler;
/**
+ * This handler is responsible for apply composite components. It
+ * is created by CompositeResourceLibrary class when a composite component
+ * is found.
+ *
* @author Leonardo Uribe (latest modification by $Author$)
* @version $Revision$ $Date$
*/
@@ -48,4 +61,64 @@
FacesContext faceContext = ctx.getFacesContext();
return faceContext.getApplication().createComponent(faceContext, _resource);
}
+
+ @Override
+ public void applyNextHandler(FaceletContext ctx, UIComponent c)
+ throws IOException
+ {
+ super.applyNextHandler(ctx, c);
+
+ applyCompositeComponentFacelet(ctx,c);
+
+ FacesContext facesContext = ctx.getFacesContext();
+
+ ViewDeclarationLanguage vdl = facesContext.getApplication().getViewHandler().
+ getViewDeclarationLanguage(facesContext, facesContext.getViewRoot().getViewId());
+
+ // TODO: This method should be called from here, but we have to retrieve
+ // its handlers from somewhere.
+ //vdl.retargetAttachedObjects(facesContext, c, handlers)
+
+ // TODO: Uncomment this code and test it.
+ //vdl.retargetMethodExpressions(facesContext, c);
+
+ if (ctx.getFacesContext().getAttributes().containsKey(
+ FaceletViewDeclarationLanguage.MARK_INITIAL_STATE_KEY))
+ {
+ // Call it only if we are using partial state saving
+ c.markInitialState();
+ // Call it to other components created not bound by a tag handler
+ c.getFacet(UIComponent.COMPOSITE_FACET_NAME).markInitialState();
+ }
+ }
+
+ protected void applyCompositeComponentFacelet(FaceletContext faceletContext, UIComponent compositeComponentBase)
+ throws IOException
+ {
+ UIPanel compositeFacetPanel = (UIPanel)
+ faceletContext.getFacesContext().getApplication().createComponent(UIPanel.COMPONENT_TYPE);
+ compositeComponentBase.getFacets().put(UIComponent.COMPOSITE_FACET_NAME, compositeFacetPanel);
+
+ VariableMapper orig = faceletContext.getVariableMapper();
+ AbstractFaceletContext actx = (AbstractFaceletContext) faceletContext;
+ try
+ {
+ faceletContext.setVariableMapper(new VariableMapperWrapper(orig));
+
+ actx.applyCompositeComponent(compositeFacetPanel, _resource);
+ }
+ finally
+ {
+ faceletContext.setVariableMapper(orig);
+ }
+ }
+
+ @Override
+ protected MetaRuleset createMetaRuleset(Class<?> type)
+ {
+ // TODO: Which metadata rules should be applied for a composite component?
+ // For now we apply the same as a default component (from delegate), but there
+ // are properties like "binding" that does not apply for.
+ return super.createMetaRuleset(type);
+ }
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeLibrary.java?rev=804815&r1=804814&r2=804815&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeLibrary.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CompositeLibrary.java Sun Aug 16 23:17:41 2009
@@ -26,12 +26,18 @@
*/
public class CompositeLibrary extends AbstractTagLibrary
{
- public final static String NAMESPACE = "http://java.sun.com/jsf/core";
+ public final static String NAMESPACE = "http://java.sun.com/jsf/composite";
- public CompositeLibrary(String namespace)
+ public CompositeLibrary()
{
super(NAMESPACE);
+ addTagHandler("interface", InterfaceHandler.class);
+
+ addTagHandler("implementation", ImplementationHandler.class);
+
+ addTagHandler("attribute", AttributeHandler.class);
+
//TODO: Add composite tag handlers
}
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java?rev=804815&r1=804814&r2=804815&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/FaceletTestCase.java Sun Aug 16 23:17:41 2009
@@ -37,6 +37,7 @@
import org.apache.myfaces.application.ApplicationFactoryImpl;
import org.apache.myfaces.application.ApplicationImpl;
+import org.apache.myfaces.application.ResourceHandlerImpl;
import org.apache.myfaces.config.FacesConfigDispenser;
import org.apache.myfaces.config.FacesConfigUnmarshaller;
import org.apache.myfaces.config.RuntimeConfig;
@@ -49,12 +50,10 @@
import org.apache.myfaces.shared_impl.util.ClassUtils;
import org.apache.myfaces.shared_impl.util.StateUtils;
import org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory;
-import org.apache.myfaces.view.facelets.compiler.Compiler;
-import org.apache.myfaces.view.facelets.compiler.SAXCompiler;
-import org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory;
import org.apache.myfaces.view.facelets.impl.ResourceResolver;
import org.apache.myfaces.view.facelets.mock.MockHttpServletRequest;
import org.apache.myfaces.view.facelets.mock.MockHttpServletResponse;
+import org.apache.myfaces.view.facelets.mock.MockResourceHandlerSupport;
import org.apache.myfaces.view.facelets.mock.MockServletContext;
import org.apache.myfaces.view.facelets.mock.MockViewDeclarationLanguageFactory;
import org.apache.myfaces.view.facelets.tag.jsf.TagHandlerDelegateFactoryImpl;
@@ -181,6 +180,11 @@
setupComponents();
setupConvertersAndValidators();
setupRenderers();
+
+ // Redirect resource request to the directory where the test class is,
+ // to make easier test composite components.
+ ((ResourceHandlerImpl)application.getResourceHandler()).
+ setResourceHandlerSupport(new MockResourceHandlerSupport(this.getClass()));
//Compiler c = new SAXCompiler();
//c.setTrimmingWhitespace(true);
Added: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java?rev=804815&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java (added)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java Sun Aug 16 23:17:41 2009
@@ -0,0 +1,65 @@
+/*
+ * 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.view.facelets.mock;
+
+import org.apache.myfaces.application.DefaultResourceHandlerSupport;
+import org.apache.myfaces.resource.ClassLoaderResourceLoader;
+import org.apache.myfaces.resource.ExternalContextResourceLoader;
+import org.apache.myfaces.resource.ResourceLoader;
+
+/**
+ * Redirect resource request to the directory where the test class is,
+ * to make easier test composite components.
+ *
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ *
+ */
+public class MockResourceHandlerSupport extends DefaultResourceHandlerSupport
+{
+ private ResourceLoader[] _resourceLoaders;
+
+ private Class _referenceClass;
+
+ public MockResourceHandlerSupport(Class class1)
+ {
+ super();
+ _referenceClass = class1;
+ }
+
+ public ResourceLoader[] getResourceLoaders()
+ {
+ if (_resourceLoaders == null)
+ {
+ //The ExternalContextResourceLoader has precedence over
+ //ClassLoaderResourceLoader, so it goes first.
+ _resourceLoaders = new ResourceLoader[] {
+ new ClassLoaderResourceLoader(getDirectory())
+ };
+ }
+ return _resourceLoaders;
+ }
+
+ private String getDirectory()
+ {
+ return _referenceClass.getName().substring(0,
+ _referenceClass.getName().lastIndexOf('.')).replace('.', '/')
+ + "/";
+ }
+}
Propchange: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/mock/MockResourceHandlerSupport.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java?rev=804815&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java (added)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java Sun Aug 16 23:17:41 2009
@@ -0,0 +1,57 @@
+/*
+ * 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.view.facelets.tag.composite;
+
+import java.io.StringWriter;
+
+import javax.faces.component.UIViewRoot;
+
+import org.apache.myfaces.view.facelets.FaceletTestCase;
+import org.apache.shale.test.mock.MockResponseWriter;
+
+public class CompositeComponentTestCase extends FaceletTestCase
+{
+
+ public void testSimpleCompositeComponent() throws Exception
+ {
+ UIViewRoot root = facesContext.getViewRoot();
+ vdl.buildView(facesContext, root, "testSimpleComposite.xhtml");
+
+ StringWriter sw = new StringWriter();
+ MockResponseWriter mrw = new MockResponseWriter(sw);
+ facesContext.setResponseWriter(mrw);
+ root.encodeAll(facesContext);
+ sw.flush();
+ System.out.print(sw.toString());
+ }
+
+ public void testSimpleCompositeAttribute() throws Exception
+ {
+ UIViewRoot root = facesContext.getViewRoot();
+ vdl.buildView(facesContext, root, "testSimpleAttribute.xhtml");
+
+ StringWriter sw = new StringWriter();
+ MockResponseWriter mrw = new MockResponseWriter(sw);
+ facesContext.setResponseWriter(mrw);
+ root.encodeAll(facesContext);
+ sw.flush();
+ System.out.print(sw.toString());
+ }
+}
Propchange: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/CompositeComponentTestCase.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/SerializableAttributesTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/SerializableAttributesTestCase.java?rev=804815&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/SerializableAttributesTestCase.java (added)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/SerializableAttributesTestCase.java Sun Aug 16 23:17:41 2009
@@ -0,0 +1,89 @@
+/*
+ * 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.view.facelets.tag.composite;
+
+import java.beans.BeanDescriptor;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.faces.component.UINamingContainer;
+
+import junit.framework.TestCase;
+
+public class SerializableAttributesTestCase extends TestCase
+{
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testSerializeCompositeResourceWrapper() throws Exception
+ {
+ CompositeResouceWrapper subject = new CompositeResouceWrapper();
+ subject.setResourceName("testRes");
+ subject.setLibraryName("testLib");
+ subject.setContentType(null);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(128);
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(subject);
+ oos.flush();
+ baos.flush();
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ CompositeResouceWrapper blorg = (CompositeResouceWrapper) ois.readObject();
+ assertEquals(blorg.getResourceName(), subject.getResourceName());
+ assertEquals(blorg.getLibraryName(), subject.getLibraryName());
+ assertEquals(blorg.getContentType(), subject.getContentType());
+ oos.close();
+ ois.close();
+ }
+
+ public void testSerializeCompositeComponentBeanInfo() throws Exception
+ {
+ BeanDescriptor descriptor = new BeanDescriptor(UINamingContainer.class);
+ CompositeComponentBeanInfo subject = new CompositeComponentBeanInfo(descriptor);
+ CompositeComponentPropertyDescriptor pd = new CompositeComponentPropertyDescriptor("attrName");
+ pd.setValue("type","someClass");
+ subject.getPropertyDescriptorsList().add(pd);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(128);
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(subject);
+ oos.flush();
+ baos.flush();
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ CompositeComponentBeanInfo blorg = (CompositeComponentBeanInfo) ois.readObject();
+
+ assertEquals(UINamingContainer.class, blorg.getBeanDescriptor().getBeanClass());
+ assertEquals(pd.getName(), blorg.getPropertyDescriptorsList().get(0).getName());
+ oos.close();
+ ois.close();
+ }
+}
Propchange: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/SerializableAttributesTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/composite/SerializableAttributesTestCase.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testComposite/simpleAttribute.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testComposite/simpleAttribute.xhtml?rev=804815&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testComposite/simpleAttribute.xhtml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testComposite/simpleAttribute.xhtml Sun Aug 16 23:17:41 2009
@@ -0,0 +1,31 @@
+<!--
+ 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.
+
+ $Id: defineInclude.xml 804043 2009-08-13 22:08:44Z lu4242 $
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:composite="http://java.sun.com/jsf/composite">
+<head>
+</head>
+<body>
+<composite:interface>
+ <composite:attribute name="style" type="java.lang.String" required="true" />
+</composite:interface>
+<composite:implementation>
+ <h:outputText value="Hello World"/>
+</composite:implementation>
+</body>
+</html>
\ No newline at end of file
Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testComposite/simpleComposite.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testComposite/simpleComposite.xhtml?rev=804815&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testComposite/simpleComposite.xhtml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testComposite/simpleComposite.xhtml Sun Aug 16 23:17:41 2009
@@ -0,0 +1,30 @@
+<!--
+ 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.
+
+ $Id: defineInclude.xml 804043 2009-08-13 22:08:44Z lu4242 $
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:composite="http://java.sun.com/jsf/composite">
+<head>
+</head>
+<body>
+<composite:interface>
+</composite:interface>
+<composite:implementation>
+ <h:outputText value="Hello World!"/>
+</composite:implementation>
+</body>
+</html>
\ No newline at end of file
Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testSimpleAttribute.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testSimpleAttribute.xhtml?rev=804815&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testSimpleAttribute.xhtml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testSimpleAttribute.xhtml Sun Aug 16 23:17:41 2009
@@ -0,0 +1,29 @@
+<!--
+ 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.
+
+ $Id: defineInclude.xml 804043 2009-08-13 22:08:44Z lu4242 $
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:testComposite="http://java.sun.com/jsf/composite/testComposite">
+<head>
+</head>
+<body>
+<testComposite:simpleAttribute>
+</testComposite:simpleAttribute>
+<testComposite:simpleAttribute>
+</testComposite:simpleAttribute>
+</body>
+</html>
\ No newline at end of file
Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testSimpleComposite.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testSimpleComposite.xhtml?rev=804815&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testSimpleComposite.xhtml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/composite/testSimpleComposite.xhtml Sun Aug 16 23:17:41 2009
@@ -0,0 +1,27 @@
+<!--
+ 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.
+
+ $Id: defineInclude.xml 804043 2009-08-13 22:08:44Z lu4242 $
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:testComposite="http://java.sun.com/jsf/composite/testComposite">
+<head>
+</head>
+<body>
+<testComposite:simpleComposite>
+</testComposite:simpleComposite>
+</body>
+</html>
\ No newline at end of file