java - Struts2 + ajax token refresh -


i'm developing web application using struts2 (ver. 2.3.24) , have massive use of ajax pagination. have form:

<s:form id="pagination-form">     <s:token id="session_token" />     <s:hidden id="entityclass" value="%{paginator.getentityclassstring()}" />     <s:hidden id="paginator-ordercolumn" value="%{paginator.ordercolumn}" />     <s:hidden id="paginator-order" value="%{paginator.order}" />     <s:hidden id="paginator-firstitem" value="%{paginator.firstitem}" />     <s:hidden id="paginator-resultscount" value="%{paginator.resultscount}" />     <s:hidden id="paginator-perpageitems" value="%{paginator.perpageitems}" />     <s:hidden id="paginator-currentpage" value="%{paginator.currentpage}" /> </s:form> 

and corresponding ajax call:

$.ajax({         url: route/to/action,         type: 'post',         data: {             'entityclass': $('#entityclass').val(),             'struts.token.name': $(form).find('input[name=\'struts.token.name\']').val(),             'token': $(form).find('input[name=token]').val(),             'paginator.ordercolumn': $('#paginator-ordercolumn').val(),             'paginator.order': $('#paginator-order').val(),             'paginator.firstitem': $('#paginator-firstitem').val(),             'paginator.resultscount': $('#paginator-resultscount').val(),             'paginator.perpageitems': $('#paginator-perpageitems').val(),             'paginator.currentpage': $('#paginator-currentpage').val()         },         datatype: 'json',         success: function (response) {             // empty table             // iterate results             // populate table         },          error: function (jqxhr, textstatus, errorthrown) {             // shows error message         }     }); 

when call, token invalidated , need refresh everytime have pagination call. i've found this question , this question concerning topic. there better ways refresh token? or, on other side, doing wrong?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -