BreadCrumb component dynamic update

UI Components for JSF
Post Reply
moonshines
Posts: 4
Joined: 19 Jul 2018, 22:16

19 Jul 2018, 22:22

Hi ,
I'm using PrimeFaces 6.2 and trying to create a dynamic breadcrumb which gets updated with page to page navigation in my application.
After seeing through numerous posts on this forum and stackoverflow this is what I have got going so far. The problem is when going from page to page my breadcrumb doesn't update.
Please suggest the right way to do it.

In header.xhtml
<p:breadCrumb model="#{breadCrumbView.breadcrumbmodel}" />

In all the other xhtml files
<f:event type="preRenderView" listener="#{breadCrumbView.onRenderView}" />
<f:attribute name="pageName" value="pageName1" />

@ManagedBean(name = "breadCrumbView")
@RequestScoped
public class BreadCrumbView implements Serializable {

public void onRenderView(ComponentSystemEvent evt) {

UIViewRoot root = (UIViewRoot) evt.getSource();
HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext()
.getRequest();
String reqUrl = req.getRequestURL().toString();
String pageName = (String) evt.getComponent().getAttributes().get("pageName");
if (pageName != null && !pageNameList.contains(pageName)) {
breadcrumbmodel.addElement(createItem(root.createUniqueId(), pageName, reqUrl));

}

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

20 Jul 2018, 13:56

Your bean is request scoped, sure you add something to the model each time or is it cleared? Please be specific how it does behave (and try with a plain h:outputText to display e.g. a list to see if the problem is breadcrumb related or plain jsf (for which StackOverflow is a better place then)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 25 guests