You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Pierce T. Wetter III" <pi...@paceap.com> on 2010/04/23 00:36:11 UTC
Menu nesting problem
Menus are inherently recursive.
In order to generate ours, I need to generate a series of UL and LI tags with class="current" on the menu for the current page, and class="currentAncestor" for the ancestors of the current page.
Example:
<UL>
<LI class="currrentAncestor"> <a t:type="pagelink" page="Index">Top Level</A>
<UL>
<LI class="currrentAncestor"> <a t:type="pagelink" page="Second">Second Level</A>
<UL>
<LI class="currrent"> <a t:type="pagelink" page="Third">Current Level</A></LI>
</UL>
</LI>
</UL>
</LI>
</UL>
To avoid problems with Tapestry and recursion, I figured out I could setup things this way, if the currentMenu has a list of its ancestors:
<t:loop source="currentMenu.ancestors" value="displayMenu">
<UL>
<LI class="currentAncestor"> <a type="pagelink" page="displayMenu.page">${displayMenu.title}</A>
</t:loop>
<LI class="currrent"> <a t:type="pagelink" page="Third">Current Level</A></LI>UL> <LI class="current"> <a type-
<t:loop source="currentMenu.ancestors" value="displayMenu">
</LI>
</UL>
</t:loop>
Problem is that's illegal XML above because I'm looping over open tags, and then below I'm looping over close tags.
Is there any clever way around this besides looping over everything and then using a delegate to insert the current menu at the bottom?
Pierce
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Menu nesting problem
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 22 Apr 2010 19:36:11 -0300, Pierce T. Wetter III
<pi...@paceap.com> wrote:
> Menus are inherently recursive.
> To avoid problems with Tapestry and recursion, I figured out I could
> setup things this way, if the currentMenu has a list of its ancestors:
For anything recursive, the best way of implementing it is to create a
component that uses a MarkupWriter to generate HTML instead of using a
template.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da
Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org