-
1. Re: Breadcrumbs within the same conversation / pageflow
gavin.king Sep 19, 2006 3:33 PM (in response to ngeadah)A page action mapped to "*" is a better choice than a servlet filter.
-
2. Re: Breadcrumbs within the same conversation / pageflow
ngeadah Sep 19, 2006 4:07 PM (in response to ngeadah)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
ngeadah Oct 8, 2006 11:45 AM (in response to ngeadah)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<pages> <page view-id="*" action="#{breadcrumb.log}"/> </pages>
2- A "breadcrumb" Seam component:@Name("breadcrumb") 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 { conversationCrumb.add(thePage); } } Contexts.getConversationContext().set("conversationCrumb",conversationCrumb); } } else { Contexts.removeFromAllContexts("conversationCrumb"); } } catch (Throwable t) { // Do nothing as this is just a "listener" for breadcrumbs t.printStackTrace(); } } public void navigate() { FacesContext context = FacesContext.getCurrentInstance(); Map map = context.getExternalContext().getRequestParameterMap(); String viewId = (String) map.get("viewId"); String pageName = (String) map.get("name"); Pageflow.instance().reposition(pageName); Redirect redirect = Redirect.instance(); redirect.setViewId(viewId); redirect.execute(); } }
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}"/> </h:commandLink> </t:dataList>
-
4. Re: Breadcrumbs within the same conversation / pageflow
gavin.king Oct 8, 2006 1:58 PM (in response to ngeadah)Why not post this "pattern" to the wiki?
-
5. Re: Breadcrumbs within the same conversation / pageflow
jpviragine Oct 11, 2006 9:31 AM (in response to ngeadah)Hi ngeadah,
I?m using your code with current cvs version and jbpm-3.1.2.jar.
The getDescription works fine.
Regards,
Joao Paulo -
6. Re: Breadcrumbs within the same conversation / pageflow
amit.rakhaiya Jul 17, 2012 1:50 AM (in response to ngeadah)conversationCrumb = (List) Contexts.lookupInStatefulContexts("conversationCrumb");
Can you please tell me what is "conversationCrumb" ??