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));
}
BreadCrumb component dynamic update
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)
-
- Information
-
Who is online
Users browsing this forum: No registered users and 41 guests