0

I have primefaces datatable. Data in the datatable, are with h:commandLink created. I have developed with jquery ajax browser back button. with the hash, location.hash="#paginator="+x; everything works without problems.

My problem is. When I click on the link first time, link does not work at first. only hash in the url will be removed. the second time it works. But then does not work browser back button. how could the h:commandLink work properly when clicking.

<script type="text/javascript">

    $("span.ui-paginator-page").live('click',function(e){
      var x = $(this).text();
      location.hash = "#paginator="+x;
      e.preventDefault();
    }); 

    $(document).ready(function(){
      window.onhashchange = ajaxhistory;
    });

    function ajaxhistory(){
      var wert2 = window.location.hash;
      jQuery.ajax({
        type: 'POST',
        data: myvalue, 
        success: function(myvalue){
          $('#content_data').load('index.xhtml #content_data');
          var fragment = document.getElementById('fragment');
          fragment.value = window.location.hash;
          fragment.onchange();
        }
      });  
   };
</script>   




<h:inputText id="fragment" value="#{paginatorBean.fragment}">
  <f:ajax event="change" execute="@form" listener="#{paginatorBean.processFragment}" />
</h:inputText>

<p:dataTable id="content_data" value="#{myDataBean.lazyModel}" var="item"
                             paginator="true" rows="10" 
                             paginatorPosition="bottom"
                             paginatorTemplate="  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "  
                             rowsPerPageTemplate="5,10,15"
                             lazy="true" 
                             >  


  <p:column >
   <h:commandLink class="mybutton" value="#{item.name} #{item.autotextcomplete}"  action="#{myDataBean.goto(item.id)}"/>

  </p:column>

0 Answers0