问题
I'm using spring portlet mvc and JQuery. The thing is that I need to submit my form when I click the pagination links from the displayTag (when I try to go to the second page for instance)
<form:form id="myForm" action="${formAction}" method="post" modelAttribute="myBean" enctype="multipart/form-data">
<portlet:actionURL var="viewListURL" portletMode="view">
<portlet:param name="action" value="${ServletContextKeys.MY_ACTION}"/>
</portlet:actionURL>
<display:table id="displayImpGasto"
name="${myList}"
requestURI="${viewListURL}"
htmlId="impList"
class="displayTagTable"
uid="imp"
pagesize="10">
<display:column>
//Whatever
</display:column>
</display:table>
</form:form>
Just doing like this, doesn't submit the form. Any idea..? Thanks in advance.
回答1:
To submit the form on the pagination links you need to overide the properties of display tag that you can do it by creating a custom properties file named displaytag.properties and place it in the application classpath (typically into WEB-INF/classes) . Their you need to define properites paging.banner.first,paging.banner.last,paging.banner.page.link for more info go through this link. for example :
paging.banner.page.link :<a onclick="this.form.action='{1}';this.form.submit();" title="Go to page {0}">{0}</a>
回答2:
Following the idea on the post above:
<script type="text/javascript">
function submitPagination(url) {
jQ("#formPagoParcial").attr('action', url);
jQ("#formPagoParcial").submit();
}
</script>
<display:setProperty name="paging.banner.page.link">
<a href="javascript:void(submitPagination('{1}'))" title="Go to page {0}">{0}</a>
</display:setProperty>
And this is working as expected.
回答3:
I solved it by inserting the table into another jsp and using the struts2 tag "include" to include it. Also, you have to use the attributes of Displaytagin your tag "display:table": - requestURI="yourAction" - excludedParams="*"
displaytable doc
来源:https://stackoverflow.com/questions/15769473/submit-form-in-a-displaytag-pagination