私はプライムフェイスのデータテーブルを持っています。データテーブル内のデータは、h:commandLink で作成されます。jquery ajaxブラウザの戻るボタンで開発しました。ハッシュ、location.hash="#paginator="+x; すべてが問題なく動作します。
私の問題です。初めてリンクをクリックすると、最初はリンクが機能しません。URL のハッシュのみが削除されます。2回目は機能します。しかし、ブラウザの戻るボタンが機能しません。クリックしたときに h:commandLink が正しく機能する方法を教えてください。
<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>