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();
}