6 Replies Latest reply on Jul 17, 2012 1:50 AM by Amit Rakhaiya

    Breadcrumbs within the same conversation / pageflow


      Hi All,

      I noticed that Seam has some rudimentary support for breadcrumbs, as outlined in the following section of the documentation:


      This is fine for nested-conversations, but does not solve the more common case of displaying the sequence of pages traveled by the user within the SAME conversation (defined using a pageflow, for example). Is there any support built-in to get the list of pages traveled within the conversation? If not, any suggestions on how to achieve this? Probably a servlet filter that keeps track of navigation but handling the back button might be a pain...


        • 1. Re: Breadcrumbs within the same conversation / pageflow
          Gavin King Master

          A page action mapped to "*" is a better choice than a servlet filter.

          • 2. Re: Breadcrumbs within the same conversation / pageflow

            Thanks Gavin.

            I will assume from your answer that breadcrumb creation in this way is not a built-in Seam component. Is this being considered as a roadmap item for the future? IMHO, breadcrumbs are more prevalent within a single conversation as opposed to the breadcrumb support from Seam which accomodates for nested conversation. The latter is nice, but the former seems (seams ;) more important.

            Thanks again!

            • 3. Re: Breadcrumbs within the same conversation / pageflow

              Here is the solution. This creates a clickable breadcrumb trail as the user moves through the pageflow. The breadcrumb trail gets correctly adjusted if the user goes back.

              1- A page action mapped to "*" in pages.xml

               <page view-id="*" action="#{breadcrumb.log}"/>

              2- A "breadcrumb" Seam component:

              public class BreadcrumbHandler {
               private List<Page> conversationCrumb;
               public void log() {
               try {
               if (Contexts.isConversationContextActive()) {
               conversationCrumb = (List) Contexts.lookupInStatefulContexts("conversationCrumb");
               if (null == conversationCrumb) conversationCrumb = new LinkedList<Page>();
               if (null != Pageflow.instance()) {
               if (null != Pageflow.instance().getPage()) {
               Page thePage = Pageflow.instance().getPage();
               if (conversationCrumb.contains(thePage)) {
               // rewind the conversation crumb to where the page is
               conversationCrumb = conversationCrumb.subList(0, conversationCrumb.indexOf(thePage)+1);
               } else {
               } else {
               } catch (Throwable t) {
               // Do nothing as this is just a "listener" for breadcrumbs
               public void navigate()
               FacesContext context = FacesContext.getCurrentInstance();
               Map map = context.getExternalContext().getRequestParameterMap();
               String viewId = (String) map.get("viewId");
               String pageName = (String) map.get("name");
               Redirect redirect = Redirect.instance();

              3- JSF tags needed to display the crumbs. This relies on the h:commandLink which creates Javascript, but it's probably pretty easy to change this to an s:link instead (although s:link won't take paramaters until the Seam 1.1 release). Also, I wish I could print out the page description instead of the page name, but Seam has a bug when calling getDescription on a page (http://jira.jboss.com/jira/browse/JBSEAM-272)

               <t:dataList value="#{conversationCrumb}" var="crumb">
               <h:outputText value=" | "/>
               <h:commandLink action="#{breadcrumb.navigate}">
               <f:param name="viewId" value="#{crumb.viewId}"/>
               <f:param name="name" value="#{crumb.name}"/>
               <h:outputText value="#{crumb.name}"/>

              • 4. Re: Breadcrumbs within the same conversation / pageflow
                Gavin King Master

                Why not post this "pattern" to the wiki?

                • 5. Re: Breadcrumbs within the same conversation / pageflow
                  Joao Viragine Newbie

                  Hi ngeadah,

                  I?m using your code with current cvs version and jbpm-3.1.2.jar.
                  The getDescription works fine.


                  Joao Paulo

                  • 6. Re: Breadcrumbs within the same conversation / pageflow
                    Amit Rakhaiya Newbie

                    conversationCrumb = (List) Contexts.lookupInStatefulContexts("conversationCrumb");

                    Can you please tell me what is "conversationCrumb" ??