Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have created a blog post explaining how to get this to work using jQuery BBQ, based on your question.</p> <p>With jQuery BBQ you can keep track of state, history and allow bookmarking while dynamically modifying the page via AJAX and/or DHTML.. just click the links, use your browser's back and next buttons, reload the page.. </p> <p>First we should include <a href="http://github.com/cowboy/jquery-bbq/raw/v1.2.1/jquery.ba-bbq.min.js" rel="noreferrer">jQuery BBQ</a>. </p> <pre><code>&lt;h:outputScript library="js" name="jquery.ba-bbq.min.js" /&gt; </code></pre> <p>Now consider we have the menu (with all our nav rules)</p> <pre><code> &lt;p:submenu label="Meat"&gt; &lt;p:menuitem outcome="/meat/steak.xhtml" value="Steak" /&gt; &lt;p:menuitem outcome="/meat/burger.xhtml" value="Burger" /&gt; &lt;p:menuitem outcome="/meat/chicken.xhtml" value="Chicken" /&gt; &lt;p:menuitem outcome="/meat/kebab.xhtml" value="Kebab" /&gt; &lt;/p:submenu&gt; </code></pre> <p>Then the centered content</p> <pre><code> &lt;pe:layoutPane id="content" position="center"&gt; &lt;h:panelGroup id="centerpanel" layout="block"&gt; &lt;ui:include id="include" src="#{mainBean.currentNav}" /&gt; &lt;/h:panelGroup&gt; &lt;/pe:layoutPane&gt; </code></pre> <p>the <em>include</em> reflects the currentNav clicked.</p> <p>now define a <em>remoteCommand</em> inside the form</p> <pre><code>&lt;p:remoteCommand name="updateNav" actionListener="#{mainBean.updateNav()}" update=":centerpanel"/&gt; </code></pre> <p>This remoteCommand will update our currentNav based on the hashtag.</p> <p>Create your JS file or include the following code into the document ready</p> <pre><code>$(document).ready(function() { $('.ui-menuitem-link').click(function(event) { event.preventDefault(); var currentNav = $(this).attr('href'). substr($(this).attr('href').indexOf("/faces") + 6) window.location.hash = '#' + currentNav; }) $(window).bind('hashchange', function(e) { var url = $.param.fragment(); updateNav([{name: 'currentNav', value: url}]); //remoteCommand Call }) $(window).trigger('hashchange'); }); </code></pre> <p>Basically first we handle our clicks on the menu items, setting the hash of the window.</p> <p>then we define an event of the hashchange of the window, using the help of jQuery BBQ.</p> <p><em>ManagedBean</em></p> <pre><code>public void updateNav() { FacesContext context = FacesContext.getCurrentInstance(); Map map = context.getExternalContext().getRequestParameterMap(); currentNav = (String) map.get("currentNav"); } </code></pre> <p>For a complete code, please see my newly post created for the question.</p> <p><a href="http://blog.hatemalimam.com/primefaces-hash-navigation-using-jquery-bbq/" rel="noreferrer">Primefaces Hash Navigation Using jQuery BBQ</a></p> <p>And also the example is available on <a href="https://github.com/hatemalimam/PrimeBBQ" rel="noreferrer">github</a>.</p> <p>Hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload