Author: hlship
Date: Wed Jan 3 16:52:12 2007
New Revision: 492372
URL: http://svn.apache.org/viewvc?view=rev&rev=492372
Log:
Add support for instrumented elements without a specific type (which
automatically use the Any component).
Add the Any component, which emulates any arbitrary element.
Added:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Any.java
tapestry/tapestry5/tapestry-core/trunk/src/test/app1/AnyDemo.html
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/AnyDemo.java
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResourcesCommon.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/parser/StartComponentToken.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactory.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactoryImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt
tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/TemplateParserImplTest.java
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResourcesCommon.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResourcesCommon.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResourcesCommon.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResourcesCommon.java
Wed Jan 3 16:52:12 2007
@@ -101,4 +101,12 @@
/** Returns the locale for the page containing this component. */
Locale getLocale();
+
+ /**
+ * Returns the name of element that represents the component in its
template, or null if the
+ * element was provided by a <comp> element.
+ *
+ * @return the element name
+ */
+ String getElementName();
}
Added:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Any.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Any.java?view=auto&rev=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Any.java
(added)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Any.java
Wed Jan 3 16:52:12 2007
@@ -0,0 +1,58 @@
+package org.apache.tapestry.corelib.components;
+
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.annotations.ComponentClass;
+import org.apache.tapestry.annotations.Environmental;
+import org.apache.tapestry.annotations.Inject;
+import org.apache.tapestry.annotations.Parameter;
+import org.apache.tapestry.annotations.SupportsInformalParameters;
+import org.apache.tapestry.services.PageRenderSupport;
+
+/**
+ * The Any component is a swiss-army knife that emulates any arbitary element.
Renders an element
+ * tag including an id attribute and any informal parameters. The id is
provided by
+ * [EMAIL PROTECTED] PageRenderSupport#allocateClientId(String)} (so it will
be unique on the client side) and
+ * is available after the component renders as [EMAIL PROTECTED]
#getClientId()}. The Any component has no
+ * template but does render its body.
+ */
[EMAIL PROTECTED]
[EMAIL PROTECTED]
+public class Any
+{
+ /**
+ * The element to be rendered by the component. Normally, this matches the
element from the
+ * template, but this can be overridden if necessary.
+ */
+ @Parameter("componentResources.elementName")
+ private String _element;
+
+ @Inject
+ private ComponentResources _resources;
+
+ @Environmental
+ private PageRenderSupport _pageRenderSupport;
+
+ private String _clientId;
+
+ void beginRender(MarkupWriter writer)
+ {
+ String componentId = _resources.getId();
+
+ _clientId = _pageRenderSupport.allocateClientId(componentId);
+
+ writer.element(_element, "id", _clientId);
+
+ _resources.renderInformalParameters(writer);
+ }
+
+ void afterRender(MarkupWriter writer)
+ {
+ writer.end();
+ }
+
+ public String getClientId()
+ {
+ return _clientId;
+ }
+}
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/parser/StartComponentToken.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/parser/StartComponentToken.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/parser/StartComponentToken.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/parser/StartComponentToken.java
Wed Jan 3 16:52:12 2007
@@ -24,7 +24,7 @@
*/
public class StartComponentToken extends TemplateToken
{
- private final String _element;
+ private final String _elementName;
private final String _id;
@@ -33,7 +33,7 @@
private final String _mixins;
/**
- * @param element
+ * @param elementName
* the name of the element from which this component was
parsed, or null if the
* element was the t:comp placeholder
* @param id
@@ -46,14 +46,14 @@
* @param location
* the location within the template at which the element was
parsed
*/
- public StartComponentToken(String element, String id, String type, String
mixins,
+ public StartComponentToken(String elementName, String id, String type,
String mixins,
Location location)
{
super(TokenType.START_COMPONENT, location);
// TODO: id or type may be null, but not both!
- _element = element;
+ _elementName = elementName;
_id = id;
_type = type;
_mixins = mixins;
@@ -66,9 +66,9 @@
*
* @return the element name or null
*/
- public String getElement()
+ public String getElementName()
{
- return _element;
+ return _elementName;
}
/**
@@ -94,7 +94,7 @@
{
StringBuilder builder = new StringBuilder();
- add(builder, "element", _element);
+ add(builder, "element", _elementName);
add(builder, "id", _id);
add(builder, "type", _type);
add(builder, "mixins", _mixins);
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactory.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactory.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactory.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactory.java
Wed Jan 3 16:52:12 2007
@@ -12,94 +12,96 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.internal.services;
-
-import org.apache.tapestry.ComponentResources;
-import org.apache.tapestry.annotations.Component;
-import org.apache.tapestry.internal.parser.AttributeToken;
-import org.apache.tapestry.internal.parser.ExpansionToken;
-import org.apache.tapestry.internal.parser.StartElementToken;
-import org.apache.tapestry.internal.parser.TextToken;
-import org.apache.tapestry.internal.structure.ComponentPageElement;
-import org.apache.tapestry.internal.structure.Page;
-import org.apache.tapestry.internal.structure.PageElement;
+package org.apache.tapestry.internal.services;
+
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.annotations.Component;
+import org.apache.tapestry.internal.parser.AttributeToken;
+import org.apache.tapestry.internal.parser.ExpansionToken;
+import org.apache.tapestry.internal.parser.StartElementToken;
+import org.apache.tapestry.internal.parser.TextToken;
+import org.apache.tapestry.internal.structure.ComponentPageElement;
+import org.apache.tapestry.internal.structure.Page;
+import org.apache.tapestry.internal.structure.PageElement;
import org.apache.tapestry.ioc.Location;
-
-/**
- * Used by the [EMAIL PROTECTED]
org.apache.tapestry.internal.services.PageLoader} to create page elements
- */
-public interface PageElementFactory
-{
- PageElement newTextElement(TextToken token);
-
- PageElement newStartElement(StartElementToken token);
-
- PageElement newAttributeElement(AttributeToken token);
-
- PageElement newEndElement();
-
- PageElement newExpansionElement(ComponentResources componentResources,
ExpansionToken token);
-
- /**
- * Creates a new component and adds it to the page and to its container.
- * <p>
- * Note: doesn't add the component as a child of the container.
- *
- * @param page
- * the page that will ultimately contain the new component
- * @param container
- * the existing component that contains the new component
- * @param id
- * the id, unique within the container, of the new component
- * @param componentType
- * the type of the component (as defined in the template or the
[EMAIL PROTECTED] Component}
- * annotation)
- * @param componentClassName
- * the fully qualfied class name used when the componentType is
blank (null or the
- * empty string)
- * @param location
- * location of the component's element with its container's
template
- * @return the newly created comopnent, after adding it to the page and
container
- */
- ComponentPageElement newComponentElement(Page page, ComponentPageElement
container, String id,
- String componentType, String componentClassName, Location
location);
-
- /**
- * Creates a new root component for a page. Adds any mixins defined by the
components model.
- *
- * @param page
- * the page that will contain the root component
- * @param className
- * the fully qualified class name of the root component
- * @return the root page element
- */
- ComponentPageElement newRootComponentElement(Page page, String className);
-
- PageElement newRenderBodyElement(ComponentPageElement component);
-
- /**
- * Adds a mixin to the element, resolving the mixin type to a mixin class.
- * <p>
- * Sure, this isn't quite a <em>factory</em> method, but PEF has all the
tools to accomplish
- * this handy, as opposed to PageLoaderImpl.
- *
- * @param component
- * the component to which a mixin will be added
- * @param mixinType
- * used to resolve the mixin class name
- */
- void addMixinByTypeName(ComponentPageElement component, String mixinType);
-
- /**
- * Adds a mixin to the element.
- * <p>
- * Sure, this isn't quite a <em>factory</em> method, but PEF has all the
tools to accomplish
- * this handy, as opposed to PageLoaderImpl.
- *
- * @param component
- * the component to which a mixin will be added
- * @param mixinClassName
- * fully qualified class name of the mixin
- */
- void addMixinByClassName(ComponentPageElement component, String
mixinClassName);
-}
+
+/**
+ * Used by the [EMAIL PROTECTED]
org.apache.tapestry.internal.services.PageLoader} to create page elements
+ */
+public interface PageElementFactory
+{
+ PageElement newTextElement(TextToken token);
+
+ PageElement newStartElement(StartElementToken token);
+
+ PageElement newAttributeElement(AttributeToken token);
+
+ PageElement newEndElement();
+
+ PageElement newExpansionElement(ComponentResources componentResources,
ExpansionToken token);
+
+ /**
+ * Creates a new component and adds it to the page and to its container.
+ * <p>
+ * Note: doesn't add the component as a child of the container.
+ *
+ * @param page
+ * the page that will ultimately contain the new component
+ * @param container
+ * the existing component that contains the new component
+ * @param id
+ * the id, unique within the container, of the new component
+ * @param componentType
+ * the type of the component (as defined in the template or the
[EMAIL PROTECTED] Component}
+ * annotation)
+ * @param componentClassName
+ * the fully qualfied class name used when the componentType is
blank (null or the
+ * empty string)
+ * @param elementName
+ * TODO
+ * @param location
+ * location of the component's element within its container's
template
+ * @return the newly created comopnent, after adding it to the page and
container
+ */
+ ComponentPageElement newComponentElement(Page page, ComponentPageElement
container, String id,
+ String componentType, String componentClassName, String
elementName, Location location);
+
+ /**
+ * Creates a new root component for a page. Adds any mixins defined by the
components model.
+ *
+ * @param page
+ * the page that will contain the root component
+ * @param className
+ * the fully qualified class name of the root component
+ * @return the root page element
+ */
+ ComponentPageElement newRootComponentElement(Page page, String className);
+
+ PageElement newRenderBodyElement(ComponentPageElement component);
+
+ /**
+ * Adds a mixin to the element, resolving the mixin type to a mixin class.
+ * <p>
+ * Sure, this isn't quite a <em>factory</em> method, but PEF has all the
tools to accomplish
+ * this handy, as opposed to PageLoaderImpl.
+ *
+ * @param component
+ * the component to which a mixin will be added
+ * @param mixinType
+ * used to resolve the mixin class name
+ */
+ void addMixinByTypeName(ComponentPageElement component, String mixinType);
+
+ /**
+ * Adds a mixin to the element.
+ * <p>
+ * Sure, this isn't quite a <em>factory</em> method, but PEF has all the
tools to accomplish
+ * this handy, as opposed to PageLoaderImpl.
+ *
+ * @param component
+ * the component to which a mixin will be added
+ * @param mixinClassName
+ * fully qualified class name of the mixin
+ */
+ void addMixinByClassName(ComponentPageElement component, String
mixinClassName);
+}
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactoryImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactoryImpl.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactoryImpl.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactoryImpl.java
Wed Jan 3 16:52:12 2007
@@ -111,13 +111,15 @@
componentResources,
componentResources,
InternalConstants.PROP_BINDING_PREFIX,
- token.getExpression(), token.getLocation());
+ token.getExpression(),
+ token.getLocation());
return new ExpansionPageElement(binding, _typeCoercer);
}
public ComponentPageElement newComponentElement(Page page,
ComponentPageElement container,
- String id, String componentType, String componentClassName,
Location location)
+ String id, String componentType, String componentClassName, String
elementName,
+ Location location)
{
String finalClassName = componentClassName;
@@ -148,7 +150,7 @@
// template.
ComponentPageElementImpl result = new ComponentPageElementImpl(page,
container, id,
- instantiator, _typeCoercer, _messagesSource, location);
+ elementName, instantiator, _typeCoercer, _messagesSource,
location);
page.addLifecycleListener(result);
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderImpl.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderImpl.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderImpl.java
Wed Jan 3 16:52:12 2007
@@ -270,6 +270,8 @@
StartComponentToken startComponent = (StartComponentToken)
token;
+ String elementName = startComponent.getElementName();
+
String embeddedType = startComponent.getType();
String embeddedId = startComponent.getId();
@@ -300,9 +302,14 @@
if (InternalUtils.isBlank(embeddedType)
&&
InternalUtils.isBlank(embeddedComponentClassName))
- throw new
TapestryException(ServicesMessages.noTypeForEmbeddedComponent(
- embeddedId,
- componentClassName), token, null);
+ {
+ if (elementName != null)
+ embeddedType = "Any";
+ else
+ throw new TapestryException(ServicesMessages
+ .noTypeForEmbeddedComponent(embeddedId,
componentClassName),
+ token, null);
+ }
ComponentPageElement newComponent =
_pageElementFactory.newComponentElement(
_page,
@@ -310,6 +317,7 @@
embeddedId,
embeddedType,
embeddedComponentClassName,
+ elementName,
startComponent.getLocation());
addMixinsToComponent(newComponent, embeddedModel,
startComponent.getMixins());
@@ -338,7 +346,7 @@
directlyInsideSubcomponent = true;
- defaultBindingPrefix = startComponent.getElement() == null
? InternalConstants.PROP_BINDING_PREFIX
+ defaultBindingPrefix = startComponent.getElementName() ==
null ? InternalConstants.PROP_BINDING_PREFIX
: InternalConstants.LITERAL_BINDING_PREFIX;
break;
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
Wed Jan 3 16:52:12 2007
@@ -290,6 +290,8 @@
private Map<String, ComponentPageElement> _children;
+ private final String _elementName;
+
private final RenderCommand _cleanupRender = new RenderCommand()
{
public void render(final MarkupWriter writer, RenderQueue queue)
@@ -412,27 +414,31 @@
* @param id
* unique (within the container) id for this component (may be
null for a root
* component)
+ * @param elementName
+ * the name of the element which represents this component in
the template, or null
+ * for <comp> element or a page component
* @param instantiator
* used to create the new component instance and access the
component's model
* @param typeCoercer
* used when coercing parameter values
* @param messagesSource
- * TODO
+ * Provides access to the component's message catalog
* @param location
* location of the element (within a template), used as part of
exception reporting
*/
public ComponentPageElementImpl(Page page, ComponentPageElement container,
String id,
- Instantiator instantiator, TypeCoercer typeCoercer,
+ String elementName, Instantiator instantiator, TypeCoercer
typeCoercer,
ComponentMessagesSource messagesSource, Location location)
{
super(location);
ComponentModel model = instantiator.getModel();
+ _page = page;
_container = container;
_id = id;
- _page = page;
+ _elementName = elementName;
_typeCoercer = typeCoercer;
_messagesSource = messagesSource;
_log = model.getLog();
@@ -477,7 +483,7 @@
public ComponentPageElementImpl(Page page, Instantiator instantiator,
TypeCoercer typeCoercer,
ComponentMessagesSource messagesSource)
{
- this(page, null, null, instantiator, typeCoercer, messagesSource,
null);
+ this(page, null, null, null, instantiator, typeCoercer,
messagesSource, null);
}
public void addEmbeddedElement(ComponentPageElement child)
@@ -919,6 +925,11 @@
public Locale getLocale()
{
return _page.getLocale();
+ }
+
+ public String getElementName()
+ {
+ return _elementName;
}
}
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
Wed Jan 3 16:52:12 2007
@@ -266,4 +266,9 @@
return _element.getComponent();
}
+ public String getElementName()
+ {
+ return _element.getElementName();
+ }
+
}
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
Wed Jan 3 16:52:12 2007
@@ -242,7 +242,8 @@
protected final void train_newComponentElement(PageElementFactory
elementFactory,
ComponentPageElement container, String embeddedId, String
embeddedType,
- String componentClassName, Location location, ComponentPageElement
embedded)
+ String componentClassName, String elementName, Location location,
+ ComponentPageElement embedded)
{
expect(
elementFactory.newComponentElement(
@@ -251,6 +252,7 @@
eq(embeddedId),
eq(embeddedType),
eq(componentClassName),
+ eq(elementName),
eq(location))).andReturn(embedded);
}
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/templates.apt Wed
Jan 3 16:52:12 2007
@@ -193,6 +193,11 @@
<<Parameters are always literal strings.>> Unlike the use of attributes with
the \<t:comp\> element,
parameter values (such as end, in the previous example)
are assumed to be literal strings. You must use the "prop:" prefix if the
value is name of a property of the component.
+
+ It is valid to specify just the t:id attribute and not supply a specific
type in either the template or in the containing class.
+ In this situation, Tapestry will make use of the
+ {{{../apidocs/org/apache/tapestry/corelib/components/Any.html}Any}}
component, a kind of placeholder for any kind of element
+ whatsoever.
Expansions
Added: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/AnyDemo.html
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/AnyDemo.html?view=auto&rev=492372
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/AnyDemo.html (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/AnyDemo.html Wed Jan
3 16:52:12 2007
@@ -0,0 +1,20 @@
+<t:comp type="Border"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+ <h1>Any Component Demo</h1>
+
+ <p>
+ Demonstrates a few things about the Any component.
+ </p>
+
+ <span t:id="title" class="title">Page Title</span>
+
+ <div t:id="heading" class="heading">Heading</div>
+
+ <div t:id="section" element="h2" class="section">Section</div>
+
+
+ <ul>
+ <t:comp type="Loop" source="1..3">
+ <li t:id="item">Item (${item.clientId})</li>
+ </t:comp>
+ </ul>
+</t:comp>
\ No newline at end of file
Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/index.html Wed Jan 3
16:52:12 2007
@@ -63,7 +63,9 @@
component parameters </li>
<li>
<a href="ValidForm.html">ValidForm</a> -- server-side
input validation</li>
-
+ <li>
+ <a href="AnyDemo.html">AnyDemo</a> -- test out the Any
component
+ </li>
</ul>
</p>
</body>
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
Wed Jan 3 16:52:12 2007
@@ -85,6 +85,12 @@
_jettyRunner = null;
}
+ private void clickAndWait(String link)
+ {
+ _selenium.click(link);
+ _selenium.waitForPageToLoad(PAGE_LOAD_TIMEOUT);
+ }
+
@Test
public void basic_output() throws Exception
{
@@ -105,12 +111,6 @@
assertTextPresent("we have basic parameters working");
}
- private void clickAndWait(String link)
- {
- _selenium.click(link);
- _selenium.waitForPageToLoad(PAGE_LOAD_TIMEOUT);
- }
-
@Test
public void basic_parameters() throws Exception
{
@@ -192,10 +192,7 @@
clickAndWait("link=Environmental Annotation Useage");
- String source = _selenium.getHtmlSource();
-
- assertTrue(source
- .contains("[<strong>A message provided by the
RenderableProvider component.</strong>]"));
+ assertSourcePresent("[<strong>A message provided by the
RenderableProvider component.</strong>]");
}
@Test
@@ -260,26 +257,40 @@
clickAndWait("link=InstanceMixin");
- String body = _selenium.getHtmlSource();
-
for (String date : dates)
{
String snippet = String.format("[%s]", date);
- assertTrue(body.contains(snippet), snippet);
+
+ assertSourcePresent(snippet);
}
clickAndWait("link=Toggle emphasis");
- body = _selenium.getHtmlSource();
-
for (String date : dates)
{
String snippet = String.format("[<em>%s</em>]", date);
- assertTrue(body.contains(snippet), snippet);
+ assertSourcePresent(snippet);
}
}
@Test
+ public void any_component()
+ {
+
+ _selenium.open(BASE_URL);
+
+ clickAndWait("link=AnyDemo");
+
+ assertSourcePresent(
+ "<span class=\"title\" id=\"title\">Page Title</span>",
+ "<div class=\"heading\" id=\"heading\">Heading</div>",
+ "<h2 class=\"section\" id=\"section\">Section</h2>",
+ "<li id=\"item\">Item (item)</li>",
+ "<li id=\"item_0\">Item (item_0)</li>",
+ "<li id=\"item_1\">Item (item_1)</li>");
+ }
+
+ @Test
public void render_phase_order()
{
_selenium.open(BASE_URL);
@@ -490,5 +501,20 @@
.getHtmlSource());
throw new AssertionError("Page did not contain '" + text + "'.");
+ }
+
+ private void assertSourcePresent(String... expected)
+ {
+ String source = _selenium.getHtmlSource();
+
+ for (String snippet : expected)
+ {
+ if (source.contains(snippet))
+ continue;
+
+ System.err.printf("Source content '%s' not found in:\n%s\n\n",
expected, source);
+
+ throw new AssertionError("Page did not contain source '" +
expected + "'.");
+ }
}
}
Added:
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/AnyDemo.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/AnyDemo.java?view=auto&rev=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/AnyDemo.java
(added)
+++
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/pages/AnyDemo.java
Wed Jan 3 16:52:12 2007
@@ -0,0 +1,17 @@
+package org.apache.tapestry.integration.app1.pages;
+
+import org.apache.tapestry.annotations.Component;
+import org.apache.tapestry.annotations.ComponentClass;
+import org.apache.tapestry.corelib.components.Any;
+
[EMAIL PROTECTED]
+public class AnyDemo
+{
+ @Component
+ private Any _item;
+
+ public Any getItem()
+ {
+ return _item;
+ }
+}
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageLoaderImplTest.java
Wed Jan 3 16:52:12 2007
@@ -141,8 +141,8 @@
"foo",
"Barney",
"foo.components.Barney",
- l,
- childElement);
+ null,
+ l, childElement);
rootElement.addToTemplate(childElement);
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/TemplateParserImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/TemplateParserImplTest.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/TemplateParserImplTest.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/TemplateParserImplTest.java
Wed Jan 3 16:52:12 2007
@@ -276,7 +276,7 @@
assertEquals(start.getId(), "fred");
assertEquals(start.getType(), "Fred");
- assertNull(start.getElement());
+ assertNull(start.getElementName());
AttributeToken attr = get(tokens, 1);
@@ -297,7 +297,7 @@
assertEquals(start.getId(), "fred");
assertEquals(start.getType(), "Fred");
- assertEquals(start.getElement(), "html");
+ assertEquals(start.getElementName(), "html");
AttributeToken attr = get(tokens, 1);
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java?view=diff&rev=492372&r1=492371&r2=492372
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java
Wed Jan 3 16:52:12 2007
@@ -158,8 +158,8 @@
replay();
- ComponentPageElementImpl cpe = new ComponentPageElementImpl(page,
container, "myid", ins,
- coercer, null, l);
+ ComponentPageElementImpl cpe = new ComponentPageElementImpl(page,
container, "myid", null,
+ ins, coercer, null, l);
try
{