Sub-components have no meaning unless there's a template. It is the
elements in the template that drive the creation of sub-components. This
should be more explicit in the documentation, and perhaps there should be a
check for components in classes without a template.
On 5/3/07, Kristian Marinkovic <[EMAIL PROTECTED]> wrote:
hi,
does anyone know how to render a Tapestry 5 component that itself
contains a component with the @Component annotation?
What i did so far is to define a template for the first component that
contains the second component as a embedded component (code below).
I'm trying to write a Stylesheet component that depends on a
RelationshipLink (... actually the <link> tag :)) (please comment
on whether you consider this component to be useful/reasonable
or not).
anyway, is this the right approach for writing (nested) components?
should i use component inheritance instead? then i do not need the
template.
g,
kris
example code:
public class Stylesheet {
@Parameter(required=true) private Asset href;
@Parameter private String media;
@Parameter private String rel;
@Parameter(value="text/css",defaultPrefix="literal") private String
type;
@Component(id="relationshipLink",parameters={"href=href","media=media","rel=rel","type=type"})
private RelationshipLink relationshipLink;
public RelationshipLink getRelationshipLink() {
return relationshipLink;
}
Stylesheet.html
<link t:id="relationshipLink" xmlns:t="http://tapestry.." />
//see http://www.w3.org/TR/html4/struct/links.html for more details on
link
public class RelationshipLink {
/*
* As the only valid location for <link> is within <head>
it will
* not check the location
*/
...
void beginRender(MarkupWriter writer) {
writer.element("link",
"href",href, "charSet",charSet, "hrefLang",
hrefLang,"media",media,"rel",rel,"rev",rev,
"target",target,"type",type);
writer.end();
}
--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind
Professional Tapestry training, mentoring, support
and project work. http://howardlewisship.com