8

As far as I know there are two "kinds" of breadcrumbs.

The static/hierarchy one

  • Works like a stack
  • Entries are pushed when a user goes "deeper" into the site
  • Entries are poped when user goes "up" into the site
  • Is the same for all users (for a given page)
  • Shows location rather than history

A simple Example would be HOME -> BIG CATEGORY -> SMALL CATEGORY -> ARTICLE

The dynamic/historical one

  • Works like a queue
  • Entries are pushed at the end when a user goes to another page
  • Entries are removed from the front when the maximum size is reached
  • Is different for each user, since it is personalized.
  • Shows timeline/history instead of location.

A simple example would be SMALL CATEGORY -> HOME -> BIG CATEGORY -> HOME

The question is:

Are there any ready-made JSF component for these types of navigation?

kazanaki
  • 7,988
  • 8
  • 52
  • 79

2 Answers2

2

see primefaces, there are lot of components and you can find breadcrumb too http://www.primefaces.org:8080/showcase/ui/breadCrumb.jsf

alehro
  • 2,198
  • 2
  • 25
  • 41
rachvela
  • 730
  • 4
  • 11
  • Nice, but this is just the presentation part. I am interested in the back-end part that leverages JSF. I could easily create with jQuery/CSS an attractive breadcrumb for users. – kazanaki May 11 '10 at 10:53
  • @kazanaki: You're contradicting your own question. You were asking for a JSF component. But you're apparently more interested how to implement one yourself. Well, it's open source. Have a look. Trinidad has also one btw. – BalusC May 11 '10 at 12:09
  • @BalusC: I understand what you are saying and perhaps my question is not clear. Assume that I choose the primeface component. Then unless I am mistaked I still need to create a server-side Data structure manually that primefaces will ONLY Render. I expected something that plugs into FACEScontext and keeps track automatically of page redirects. Otherwise what do I gain from primefaces than a simple iterator and h:outputtext on this data structure? I don't want to implement anything myself. Less code is the best. But I fill that with the primefaces component I do not really gain anything. – kazanaki May 11 '10 at 13:49
  • You basically want a 3rd party filter or phaselistener which adds the current URL or viewid to some list in the session scope? – BalusC May 11 '10 at 13:54
  • @BalusC Yes something like this would be great! – kazanaki May 13 '10 at 08:24
  • @Rachvela My question was not clear. Sorry for this. Since it is my mistake I upvoted and accepted your answer. – kazanaki May 13 '10 at 08:25
0

I have the same issue! But I feel like the solution will be the one mentioned by @BalusC

Now, I am using the breadcrumb only to get the current view path.

 <h:form id="breadcrumb">
                        <p:breadCrumb>
                            <p:menuitem value="#{bundle.Index}" action="/index?faces-redirect=true" immediate="true"/>
                            <p:menuitem value="#{view.viewId.substring(0, view.viewId.length()-6)}" url="#{view.viewId.substring(0, view.viewId.length()-6)}.jsf" ajax="false"/>

                        </p:breadCrumb>
                    </h:form>

I am using .jsf as Faces URL pattern and since the viewid = /*.xhtml**, I had to substring it, remove the .xhtml substring and add the .jsf string.

So we need a backing bean that does the job of getting the viewid (path) and put it in an ordered List. The use of javascript:history.back() and history.forward() is also possible!

Hanynowsky
  • 2,970
  • 5
  • 32
  • 43