Fórumok

Jquery DataTables10.2 in Liferay

Rohan Meher, módosítva 9 év-val korábban

Jquery DataTables10.2 in Liferay

New Member Bejegyzések: 4 Csatlakozás dátuma: 2014.08.14. Legújabb bejegyzések
JSP Code

<script>
 $(document).ready(function() {
 var oTable = $('#tableId').dataTable( {
	        		  "processing": true,
	        		   "ajax": {
	        		   				"url": "../ESearch",
	        		   				"dataSrc": "demo",
	        		  				"type": "GET"
	        		  }
	        		  } );
  } );

<script>
<body>
<table id="tableId">
<thead>
<tr>
<th width="10%">First Name</th>
<th width="10%">Last Name</th>
<th width="10%">Address 1</th>
<th width="10%">Address 2</th>
</tr>
</thead>
</table>

</body>
</code></pre><br /><br /><br />The Servlet Code is<br /><pre><code>
package com.cardholdersearch;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Portlet implementation class EmployeeSearch
 */
@WebServlet("/ESearch")
public class EmployeeSearch extends HttpServlet {
	
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();
		String json = "{ \"demo\":[[\"John\",\"Sam\",\"Sola\",\"Accun\"],[\"Raj\",\"Raj\",\"Sanjosh\",\"CA\"]]}";
		out.println(json);
	}


}


</code></pre><br /><br />I am unable to communicate JSP with Servlet on ready function. Can anybody help me with the communication between jsp and servlet?</script>
thumbnail
Dave Weitzel, módosítva 9 év-val korábban

RE: Jquery DataTables10.2 in Liferay

Regular Member Bejegyzések: 208 Csatlakozás dátuma: 2009.11.18. Legújabb bejegyzések
Liferay is a portal and so you should be using the portletRequests not servlet requests that is fundamentally your problem

Ajax calls are handled by the serveResource method in the portlet standards

There are examples in the Developer documentation and Liferay in Action book