I'm beginner with Liferay, and I would Like to make an ajax call. What i am doing is: - I have a button In the jsp page to make the ajax call a variable is initialized in the javascript code, and incremented every time the user clicks on the button. this variable is transmeted to the server to be used as a parameter of a function.
Code Snippet
aui_ajax.jsp:
<input type="button" value = "Ajouter un projet" onClick="<portlet:namespace/>Test();return false;">
<div id="usersTable">
<input type="button" value = "Ajouter un projet" onClick=" <portlet:namespace/>Test();return false;">
</div>
<div id="wait" style="display:none; width: 69px; height: 89px; border: 1px solid black; position: absolute; top: 50%; left: 50%; padding: 2px;">
<img src='http://www.w3schools.com/jquery/demo_wait.gif' width="64" height="64" /> <br>Loading..
</div>
<script>
var i=1
function <portlet:namespace/>Test() {
var i=1;
AUI().use('aui-base','aui-io-request', function(A){
i++;
A.one('#wait').setStyle('display', 'block');
var allRows=A.one('#usersTable').getHTML();
var querystring = 'message:' + '1';
//aui ajax call to get updated content
A.io.request('<%=updaContentURL%>',{
dataType: 'json',
method: 'GET',
data: querystring,
on: {
success: function() {
var data=this.get('responseData');
A.Array.each(data, function(obj, idx){
var tableRow=obj.firstName;
//allRows=allRows.trim()+tableRow.trim();
//A.one('#usersTable').empty();
//A.one('#usersTable').setHTML(tableRow.trim());
A.one('#usersTable').append(tableRow.trim());
A.one('#wait').setStyle('display','none');
});
}
}
});
});
}
</script>
ContentAutoUpdateAction.java
public class ContentAutoUpdateAction extends MVCPortlet {
public void serveResource(ResourceRequest resourceRequest,
ResourceResponse resourceResponse)
throws IOException, PortletException {
try {
System.out.println("====serveResource========");
JSONObject jsonUser=null;
JSONArray usersJsonArray=JSONFactoryUtil.createJSONArray();
resourceRequest.getParameter("message");
int i=Integer.parseInt(message);
i++;
System.out.println(i);
//}
PrintWriter out=resourceResponse.getWriter();
System.out.println(usersJsonArray.toString());
out.print(usersJsonArray.toString());
}
catch (Exception e) {
e.printStackTrace();
}
}
the problem is that I can't get the parameter "message" in the ContentAutoUpdateAction.java