0

JSF 2.1 + Primefaces 5.3

I have a dynamic Primefaces MenuBar. The outcome="#{menuitem.link}" is a 'page.xhtml'

<p:menubar>
    <c:forEach items="#{USER_MENU_ITEMS}" var="menuitem" varStatus="status">
        <p:menuitem value="#{menuitem.name}" outcome="#{menuitem.link}"/>
        <c:if test="${!status.last}"><p:separator /></c:if>
    </c:forEach>
</p:menubar>

All the Managed Beans are @ViewScoped. The problem I am facing is that when I click on the menu item (that I already have worked on earlier), it navigates me to the respective page with all the data from the previous visit. I tried to append ?faces-redirect=true but that too did not work.

header.xhtml

<ui:composition ...>
    <h:form id="headerform">
        <p:menubar>
            <c:forEach items="#{USER_MENU_ITEMS}" var="menuitem" varStatus="status">
                <p:menuitem value="#{menuitem.name}" outcome="#{menuitem.link}"/>
                <c:if test="${!status.last}"><p:separator /></c:if>
            </c:forEach>
        </p:menubar>
    </h:form>
</ui:composition>

pageB.xhtml

<html ...>
    <ui:include src="./header.xhtml" />
    <h:form id="pageBForm">
        -- Uses pageBBean (@ViewScoped) properties and methods
    </h:form>
</html>

pageA.xhtml

<html ...>
    <ui:include src="./header.xhtml" />
    <h:form id="pageAForm">
        -- Uses pageABean (@ViewScoped) properties and methods
    </h:form>
</html>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
GSS
  • 3
  • 1
  • 5
  • so when you go to the next page the viewscoped bean from previous page is still alive? – Maciej Kowalski Jan 26 '17 at 21:02
  • Yes. The data in the bean is still there. Just in case if it matters, this code is in header.xhtml that is included in all other xhtmls. – GSS Jan 26 '17 at 21:10
  • Show code in [mcve] flavour. Otherwise I'd have to say 'cannot' reproduce. And 5.x is not a version... 5.0, 5.1, 5.2 and 5.3 are. Does it fail in all? Tried 6.0? (try!, not stating to use in production) – Kukeltje Jan 26 '17 at 21:51
  • Tried all versions stated. Added more code to the question. @Kukeltje - Any Ideas? – GSS Jan 26 '17 at 22:40
  • Cannot try to reproduce based on the code that is posted. It is not a [mcve] (e.g. beans are missing). Separate remark is that `h:head` is missing – Kukeltje Jan 27 '17 at 00:08
  • @BalusC - You are always the rescuer! Thank You! – GSS Jan 27 '17 at 16:31

0 Answers0