The Artima Developer Community
Sponsored Link

Java Buzz Forum
Building Bread Crumbs with Tiles and Struts

2 replies on 1 page. Most recent reply: Aug 13, 2003 10:28 AM by Cal Holman

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Cal Holman

Posts: 18
Nickname: holmanc
Registered: Aug, 2003

Cal Holman is Manager for Web Applications at Paymentech
Building Bread Crumbs with Tiles and Struts Posted: Aug 13, 2003 10:28 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Cal Holman.
Original Post: Building Bread Crumbs with Tiles and Struts
Feed Title: Cal Holman's Blog
Feed URL: http://www.calandva.com/holmansite/do/rss/CreateRssFile?type=blog
Feed Description: CalAndVA.com is built on many Java Open Source projects - this is a blog on the site progress
Latest Java Buzz Posts
Latest Java Buzz Posts by Cal Holman
Latest Posts From Cal Holman's Blog

Advertisement
Let me preface this with the facts: i am not very technical so there are probably many out there that can do what i am demonstrating in a 'better' manner. I used the ideas from the Tiles creator himself - Cedric Dumoulin (thanks for a great tool) and his advanced manual to create my site. This is a small part of the site demonstrating the use of bread crumbs and Tiles. I love Tiles and probably tend to over use the framework. You will need to download the Crumb.war

There are two techniques used in this app for bread crumb generation. The first is to write a Tiles Action that accesses the Tiles definition and the second is a tag that reads the tiles definition. Both have advantages. Using the Tiles Action you can extend the functionality of the class to provide additional Tiles based services. Using the tag is super easy and reduces the overhead of an additional action class.

The three crumb bars on each page display - from the top - the Tiles Action technique, the default (almost - style class added) crumb tag and the third the crumb tag with a different style class and separator. You have probably already clicked about a figured out how they work - but let me describe the Tiles Action first.

The Tiles Action is triggered by adding a controllerUrl attribute to the definition - in this case i am using controllerUrl="/do/renderCrumb". renderCrumb extends Tiles Action and is called whenever the corresponding Tiles Definition is triggered - this includes any controllerUrl that is in a parent definition. Since i attached the controllerUrl to my base definition it will be called for each page (I only link to definitions). Anyway in the renderCrumb action the Tiles Component Context is read giving us access to the current definition - including all the inherited definitions. So the crumb attributes are accessed as well as the page name attribute. This depends on the crumb link and title attributes following a specific naming convention. Each level of the site must inherit it's definition from it's parent and add a set of crumb attributes incrementing the level number on the end of the attribute.

In the Crumbs Action i extended the ability of the Tiles Action to read and load another attribute (of course this is pretty easy to get directly in the jsp as well). This allows some menu styling based on the current Tiles definition. Some additional things you can do in a Tiles Action is play with the definition - change an attribute or even change the template. For an example of this go to my personal site settings page. Here i change the master template used and the stylesheet based on the user's selection.

Tiles Actions are pretty handy - if you select the portal view each of the little list boxes on the right side of the screen are individual jsps with their own action classes. This allows to each to be used on any jsp and the Action Class for the jsp does not need to know the other tile is there. The little tile can load it's own beans without depending on the page it is included in. Additionally i am using osCache to cache the portal tiles since executing 6 or 7 Action Classes per page is a bit much. The support projects page has all the support projects i am using.

The Tiles Action version displays the root (home) crumb but the Crumb Tag does not - you can modify both. The Crumb Tag needs no attributes if you name your crumb link and title crumblink and crumbtitle. If you are inclined you can change the style, separator character, and names of the crumb attributes in the Tiles definition.xml.

The only "bad" part of all this is - you need to use tiles for your site layout in a structured manner. This may make this technique not right for your site. You could get the crumb definitions from another source in the Tiles Action using a page attribute as a key to a database or xml file.

Again - none of this is original, Cedric provided the code for the Tiles Action and Steve Melzer wrote the tag which i extended.

Read: Building Bread Crumbs with Tiles and Struts


bug not

Posts: 41
Nickname: bugmenot
Registered: Jul, 2004

Re: Building Bread Crumbs with Tiles and Struts Posted: Nov 30, 2006 7:58 AM
Reply to this message Reply
Too bad, the link is broken :(

Cal Holman

Posts: 18
Nickname: holmanc
Registered: Aug, 2003

Re: Building Bread Crumbs with Tiles and Struts Posted: Apr 8, 2007 11:40 AM
Reply to this message Reply
The link is now:
http://www.calandva.com/holmansite/do/myblog/blogging?date=20030711#094831

Flat View: This topic has 2 replies on 1 page
Topic: Mute a Gmail thread with 'm' Previous Topic   Next Topic Topic: Book lists

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use