Created
April 10, 2013 15:11
-
-
Save neophob/5355467 to your computer and use it in GitHub Desktop.
jsp taglib, lazy loading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struts-action config (configure webservice): | |
<action | |
path="/show_xxx_XHR" | |
type="xxx.webapp.action.XXX_XHRAction" | |
name="dummyForm" | |
scope="request" | |
input="failure" | |
parameter="method" | |
unknown="false" | |
validate="false" | |
roles="admin,support"> | |
</action> | |
the webservice: | |
public class XXX_XHRAction extends Action { | |
public ActionForward execute(ActionMapping mapping, ActionForm inForm, HttpServletRequest request, HttpServletResponse response) throws Exception { | |
log.debug("hello ajax!"); | |
DatatablesCriterias dc = DatatablesCriterias.getFromRequest(request); | |
log.debug(dc); | |
List<AssetType> assetType = DAO CALL | |
Long count = 500L; | |
Long countFiltered = (long)assetType.size(); | |
DataSet<AssetType> dataset = new DataSet<AssetType>(assetType, count, countFiltered); | |
DatatablesResponse<AssetType> resp = DatatablesResponse.build(dataset, dc); | |
//get output | |
response.setContentType("application/json"); | |
PrintWriter out = response.getWriter(); | |
//jackson converter | |
ObjectMapper mapper = new ObjectMapper(); | |
mapper.writeValue(out, resp); | |
out.flush(); | |
log.debug("done"); | |
return null; | |
} | |
the jsp: | |
<datatables:table id="myTableId" data="${assetTypList}" cssClass="table table-striped" export="csv" url="/show_xxx_XHR.html" serverSide="true" processing="true" pipelining="true" pipeSize="6"> | |
<datatables:column title="id" property="id" sortable="true" filterable="false"/> | |
<datatables:column title="name" property="name" sortable="true" filterable="true"/> | |
<datatables:export type="csv" includeHeader="false" fileName="my-export-name" cssClass="btn" label="CSV without header row" /> | |
</datatables:table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment