0

I have a problem with url refreshing after clicking on a menuItem.

I have a dataTable with the following dropdown menu with two menuItems:

<h:form id="form1">
        <p:dataTable id="singleDT" var="emp" value="#{adminBean.employees}"
            selectionMode="single" scrollable="true"
            selection="#{adminBean.selectedEmployee}" rowKey="#{emp.id}">

            <f:facet name="header">Employees

            <h:form>
                    <p:growl id="growl" showDetail="true" />

                    <p:menuButton value="Add new Employee">
                        <p:menuitem value="Add Hourly" url="/faces/addHourly.xhtml" icon="ui-icon-plus"/>
                        <p:separator />
                        <p:menuitem value="Add Flat" url="/faces/addFlat.xhtml" icon="ui-icon-plus"/>   
                    </p:menuButton>
                </h:form>

            </f:facet>
...
...
...

The problem is that when I click for istance on the Add Hourly menuItem, I can get to the addHourly.xhtml page correctly, but when I come back to my main page, the address bar of browser remains with the url /faces/addHourly.xhtml so if I refresh the page I always go to /faces/addHourly.xhtml.

How can I solve the problem?

Riccardo
  • 289
  • 2
  • 5
  • 17
  • 1
    Nested forms are not allowed, not in jsf, not in plain html. Start by correcting that first! – Kukeltje Dec 19 '16 at 14:39
  • I eliminated the nested form, but the problem is still there – Riccardo Dec 19 '16 at 14:46
  • The 'homepage' menuitem in http://www.primefaces.org/showcase/ui/menu/menuButton.xhtml works for me. Clicking it brings me to that corresponding page and pressing back in the browser shows me http://www.primefaces.org/showcase/ui/menu/menuButton.xhtml again. So please be more specific in your problem – Kukeltje Dec 19 '16 at 19:07
  • I do not have an homepage button. My problem is not in the "navigation system" but it's in the address bar of the browser. I think that it's impossibile to explain better than I did – Riccardo Dec 19 '16 at 19:32
  • What is shown in the address bar is related to the navigation system e.g. http://stackoverflow.com/questions/15521451 and you have a kind of homepage, at least the code is the same. So unless you create a [mcve] that demonstrates the problem, I'd say 'works for me' (showcase runs latest PF, what do you run), and _"but when I come back to my main page"_ is not specific... HOW do you navigate back? With a 'post' like in the link I provided in this comment? – Kukeltje Dec 19 '16 at 20:01
  • I come back with a "back" button, but when I come back the address bar remain on the "addHourly" page, so that if I refresh the page I go to addhourly page. I cannot explain better – Riccardo Dec 19 '16 at 20:26
  • As I expected, your problem IS with the navigation system. It is with 99% certainty what is described in the question I referred to above – Kukeltje Dec 19 '16 at 21:00
  • Possible duplicate of [How to navigate in JSF? How to make URL reflect current page (and not previous one)](http://stackoverflow.com/questions/15521451/how-to-navigate-in-jsf-how-to-make-url-reflect-current-page-and-not-previous-o) – Kukeltje Dec 19 '16 at 21:01

0 Answers0