ok ignore that, bumped into some tapestry4 source would this be the approach?
JSONObject <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-json/5.3.1/org/apache/tapestry5/json/JSONObject.java#JSONObject> spec = new JSONObject <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-json/5.3.1/org/apache/tapestry5/json/JSONObject.java#JSONObject>("clientId", clientId); 171 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#171> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> 172 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#172> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> e.attribute <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/dom/Element.java#Element.attribute%28java.lang.String%2Cjava.lang.String%29>("id", clientId); 173 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#173> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> 174 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#174> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> spec.put <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-json/5.3.1/org/apache/tapestry5/json/JSONObject.java#JSONObject.put%28java.lang.String%2Cjava.lang.Object%29>("leaf", node.isLeaf <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/tree/TreeNode.java#TreeNode.isLeaf%28%29>()); 175 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#175> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> 176 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#176> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> if (hasChildren) 177 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#177> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> { 178 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#178> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> Link <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/Link.java#Link> expandChildren = resources <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#Tree.0resources>.createEventLink <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/ComponentResourcesCommon.java#ComponentResourcesCommon.createEventLink%28java.lang.String%2Cjava.lang.Object%5B%5D%29>("expandChildren", node.getId <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/tree/TreeNode.java#TreeNode.getId%28%29>()); 179 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#179> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> Link <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/Link.java#Link> markExpanded = resources <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#Tree.0resources>.createEventLink <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/ComponentResourcesCommon.java#ComponentResourcesCommon.createEventLink%28java.lang.String%2Cjava.lang.Object%5B%5D%29>("markExpanded", node.getId <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/tree/TreeNode.java#TreeNode.getId%28%29>()); 180 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#180> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> Link <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/Link.java#Link> markCollapsed = resources <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#Tree.0resources>.createEventLink <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/ComponentResourcesCommon.java#ComponentResourcesCommon.createEventLink%28java.lang.String%2Cjava.lang.Object%5B%5D%29>("markCollapsed", node.getId <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/tree/TreeNode.java#TreeNode.getId%28%29>()); 181 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#181> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> 182 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#182> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> spec.put <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-json/5.3.1/org/apache/tapestry5/json/JSONObject.java#JSONObject.put%28java.lang.String%2Cjava.lang.Object%29>("expandChildrenURL", expandChildren.toString <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/lang/Object.java#Object.toString%28%29>()) 183 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#183> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> .put <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-json/5.3.1/org/apache/tapestry5/json/JSONObject.java#JSONObject.put%28java.lang.String%2Cjava.lang.Object%29>("markExpandedURL", markExpanded.toString <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/lang/Object.java#Object.toString%28%29>()) 184 <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#184> <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-core/5.3.1/org/apache/tapestry5/corelib/components/Tree.java#> .put <http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tapestry/tapestry-json/5.3.1/org/apache/tapestry5/json/JSONObject.java#JSONObject.put%28java.lang.String%2Cjava.lang.Object%29>("markCollapsedURL", markCollapsed.toString <http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/lang/Object.java#Object.toString%28%29>()); On Mon, Mar 21, 2016 at 10:47 AM, Qbyte Consulting < qbyteconsult...@gmail.com> wrote: > Tree uses BaseComponent that doesn't seem to be in tapestry5? > > On Fri, Mar 18, 2016 at 2:15 PM, Chris Poulsen <mailingl...@nesluop.dk> > wrote: > >> Hi, >> >> Take a look at the Tapestry Tree component to see how recursive rendering >> can be done. >> >> -- >> Chris >> >> On Fri, Mar 18, 2016 at 6:17 AM, Qbyte Consulting < >> qbyteconsult...@gmail.com >> > wrote: >> >> > I am creating a Menu component (for a ul tag) that needs to >> > programmatically generate the child links. >> > >> > I already have a MenuItem component, but this is parameter bound to a >> > template, whereas now I need to programmatically drive the parameters. >> > >> > I either need to be able to create the existing MenuItem objects >> somehow in >> > the Menu component and render them, or I simply write the links out in >> the >> > menu - however since my Menu component isn't extending AbstractLink >> (like >> > MenuItem) I can't use writeLink(). >> > >> > Any ideas what is the simplest approach to resolve this? Code below. >> > >> > John >> > >> > >> > public class Menu { >> > >> > /** The text. */ >> > @Parameter(required = true, allowNull = false, defaultPrefix = >> > BindingConstants.LITERAL) >> > private String name; >> > >> > /** The resources. */ >> > @Inject >> > private ComponentResources resources; >> > >> > /** The component source. */ >> > @Inject >> > private ComponentSource componentSource; >> > >> > @Inject >> > private PageRenderLinkSource linkSource; >> > >> > /** The messages. */ >> > @Inject >> > private Messages messages; >> > >> > @Inject >> > private MenuService menuService; >> > >> > /** The state bean. */ >> > @SessionState(create = false) >> > private SessionStateBean stateBean; >> > >> > /** >> > * If provided, this is the activation context for the target page >> (the >> > * information will be encoded into the URL). If not provided, then >> the >> > * target page will provide its own activation context. >> > */ >> > @Parameter >> > private Object[] context; >> > >> > /** >> > * Begin render. >> > * >> > * @param writer the writer >> > */ >> > void beginRender(MarkupWriter writer) { >> > writer.element("ul"); >> > for (String pageName : >> > menuService.getPageNames(MenuService.Menu.valueOf(name))) { >> > renderMenuItem(pageName, writer); >> > } >> > } >> > >> > private void renderMenuItem(String page, MarkupWriter writer) { >> > Link link = resources.createPageLink(page, >> > resources.isBound("context"), context); >> > writer.element("li"); >> > NO!! writeLink(writer, link); >> > writer.writeRaw(messages.get(page.toLowerCase().concat(".link"))); >> > writer.end(); >> > writer.end(); >> > } >> > >> > /** >> > * After render. >> > * >> > * @param writer the writer >> > */ >> > void afterRender(MarkupWriter writer) { >> > writer.end(); >> > } >> > } >> > >> > >> > public class MenuItem extends AbstractLink { >> > >> > /** >> > * The logical name of the page to link to. >> > */ >> > @Parameter(required = true, allowNull = false, defaultPrefix = >> > BindingConstants.LITERAL) >> > private String page; >> > >> > /** The text. */ >> > @Parameter(required = true, allowNull = false, defaultPrefix = >> > BindingConstants.LITERAL) >> > private String text; >> > >> > /** The resources. */ >> > @Inject >> > private ComponentResources resources; >> > >> > /** The component source. */ >> > @Inject >> > private ComponentSource componentSource; >> > >> > /** The state bean. */ >> > @SessionState(create = false) >> > private SessionStateBean stateBean; >> > >> > /** >> > * If provided, this is the activation context for the target page >> (the >> > * information will be encoded into the URL). If not provided, then >> the >> > * target page will provide its own activation context. >> > */ >> > @Parameter >> > private Object[] context; >> > >> > /** >> > * Begin render. >> > * >> > * @param writer the writer >> > */ >> > void beginRender(MarkupWriter writer) { >> > if (isDisabled()) >> > return; >> > Link link = resources.createPageLink(page, >> > resources.isBound("context"), context); >> > writer.element("li"); >> > writeLink(writer, link); >> > writer.writeRaw(text); >> > } >> > >> > /** >> > * After render. >> > * >> > * @param writer the writer >> > */ >> > void afterRender(MarkupWriter writer) { >> > if (isDisabled()) >> > return; >> > writer.end(); >> > writer.end(); >> > } >> > } >> > >> > >