You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by mi...@apache.org on 2003/10/16 19:47:13 UTC
cvs commit: jakarta-tapestry/framework/src/org/apache/tapestry/resolver ComponentSpecificationResolver.java
mindbridge 2003/10/16 10:47:13
Modified: framework/src/org/apache/tapestry/components Any.jwc
framework/src/org/apache/tapestry
BaseComponentTemplateLoader.java
framework/src/org/apache/tapestry/resolver
ComponentSpecificationResolver.java
Log:
Modifying the behaviour of the templateTag parameter.
It is now not added automatically to the component's spec.
If the component is interested in the tag with which it was inserted,
it must define a 'templateTag' parameter and Tapestry will automatically
bind it to the tag with which it was inserted in the parent component's template.
Revision Changes Path
1.4 +7 -1 jakarta-tapestry/framework/src/org/apache/tapestry/components/Any.jwc
Index: Any.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/components/Any.jwc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Any.jwc 21 Jun 2003 21:25:21 -0000 1.3
+++ Any.jwc 16 Oct 2003 17:47:12 -0000 1.4
@@ -16,4 +16,10 @@
</description>
</parameter>
+ <parameter name="templateTag" type="java.lang.String" direction="auto" required="no" default-value="null">
+ <description>
+ The tag used to add this component in a template.
+ </description>
+ </parameter>
+
</component-specification>
1.13 +59 -42 jakarta-tapestry/framework/src/org/apache/tapestry/BaseComponentTemplateLoader.java
Index: BaseComponentTemplateLoader.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/BaseComponentTemplateLoader.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- BaseComponentTemplateLoader.java 6 Aug 2003 14:28:48 -0000 1.12
+++ BaseComponentTemplateLoader.java 16 Oct 2003 17:47:12 -0000 1.13
@@ -369,49 +369,67 @@
{
IComponentSpecification spec = component.getSpecification();
- // add a static binding carrying the template tag
- addStaticBinding(
- component,
- spec,
- ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME,
- token.getTag(),
- token.getLocation());
-
Map attributes = token.getAttributesMap();
- if (attributes == null)
- return;
+ if (attributes != null)
+ {
+ Iterator i = attributes.entrySet().iterator();
- Iterator i = attributes.entrySet().iterator();
+ while (i.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) i.next();
- while (i.hasNext())
- {
- Map.Entry entry = (Map.Entry) i.next();
+ String name = (String) entry.getKey();
+ TemplateAttribute attribute = (TemplateAttribute) entry.getValue();
+ AttributeType type = attribute.getType();
- String name = (String) entry.getKey();
- TemplateAttribute attribute = (TemplateAttribute) entry.getValue();
- AttributeType type = attribute.getType();
+ if (type == AttributeType.OGNL_EXPRESSION)
+ {
+ addExpressionBinding(
+ component,
+ spec,
+ name,
+ attribute.getValue(),
+ token.getLocation());
+ continue;
+ }
- if (type == AttributeType.OGNL_EXPRESSION)
- {
- addExpressionBinding(
- component,
- spec,
- name,
- attribute.getValue(),
- token.getLocation());
- continue;
- }
+ if (type == AttributeType.LOCALIZATION_KEY)
+ {
+ addStringBinding(
+ component,
+ spec,
+ name,
+ attribute.getValue(),
+ token.getLocation());
+ continue;
+ }
- if (type == AttributeType.LOCALIZATION_KEY)
- {
- addStringBinding(component, spec, name, attribute.getValue(), token.getLocation());
- continue;
+ if (type == AttributeType.LITERAL)
+ addStaticBinding(
+ component,
+ spec,
+ name,
+ attribute.getValue(),
+ token.getLocation());
}
+ }
+
- if (type == AttributeType.LITERAL)
- addStaticBinding(component, spec, name, attribute.getValue(), token.getLocation());
+ // if the component defines a templateTag parameter and
+ // there is no established binding for that parameter,
+ // add a static binding carrying the template tag
+ if (spec.getParameter(ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME) != null
+ && component.getBinding(ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME) == null)
+ {
+ addStaticBinding(
+ component,
+ spec,
+ ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME,
+ token.getTag(),
+ token.getLocation());
}
+
}
/**
@@ -643,15 +661,14 @@
{
if (j == 1)
buffer.append(' ');
+ else if (j == count)
+ {
+ buffer.append(' ');
+ buffer.append(Tapestry.getMessage("BaseComponent.and"));
+ buffer.append(' ');
+ }
else
- if (j == count)
- {
- buffer.append(' ');
- buffer.append(Tapestry.getMessage("BaseComponent.and"));
- buffer.append(' ');
- }
- else
- buffer.append(", ");
+ buffer.append(", ");
buffer.append(i.next());
1.11 +1 -28 jakarta-tapestry/framework/src/org/apache/tapestry/resolver/ComponentSpecificationResolver.java
Index: ComponentSpecificationResolver.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/resolver/ComponentSpecificationResolver.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ComponentSpecificationResolver.java 21 Jun 2003 21:25:22 -0000 1.10
+++ ComponentSpecificationResolver.java 16 Oct 2003 17:47:12 -0000 1.11
@@ -63,11 +63,7 @@
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.IResourceLocation;
import org.apache.tapestry.Tapestry;
-import org.apache.tapestry.engine.ITemplateSource;
-import org.apache.tapestry.spec.Direction;
import org.apache.tapestry.spec.IComponentSpecification;
-import org.apache.tapestry.spec.IParameterSpecification;
-import org.apache.tapestry.spec.ParameterSpecification;
/**
* Utility class that understands the rules of component types (which
@@ -217,10 +213,6 @@
null);
}
-
- // This code is here because this is the centralized location that combines
- // execution flow for all kinds of templates (standard, by extension, etc)
- establishDefaultParameters();
}
private void searchForComponent(IRequestCycle cycle)
@@ -304,24 +296,5 @@
namespace.installComponentSpecification(_type, specification);
}
-
-
- private void establishDefaultParameters()
- {
- IComponentSpecification specification = getSpecification();
- if (specification.getParameter(ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME) == null)
- {
- // Add a templateTag parameter
- IParameterSpecification parameter = new ParameterSpecification();
- parameter.setPropertyName(ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME);
- parameter.setDirection(Direction.AUTO);
- parameter.setType("java.lang.String");
- parameter.setDefaultValue("null");
- parameter.setLocation(specification.getLocation());
- parameter.setRequired(false);
-
- specification.addParameter(ITemplateSource.TEMPLATE_TAG_PARAMETER_NAME, parameter);
- }
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org