Planned maintenance is scheduled for the week of June 15th - the exact date and time will be announced soon.
See More Details
Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
how to get array of ajax value in action class
This is my javascript code.
function getCommitteCode(val){
var regions = $("#<portlet:namespace/>countryId").val();
var selectednumbers = [];
$('#<portlet:namespace/>countryId :selected').each(function(i, selected) {
selectednumbers = $(selected).val();
});
console.log(selectednumbers);
$.ajax({
url : '${getRegion}',
data: {
<portlet:namespace/>reg:selectednumbers
},
type : 'POST',
dataType: "text",
success : function(data) {
}
});
}
action class code
String[] organizationId = ParamUtil.getParameterValues(resourceRequest, "reg");
am getting null values . pls help some one on this.
Thank you in advance
function getCommitteCode(val){
var regions = $("#<portlet:namespace/>countryId").val();
var selectednumbers = [];
$('#<portlet:namespace/>countryId :selected').each(function(i, selected) {
selectednumbers = $(selected).val();
});
console.log(selectednumbers);
$.ajax({
url : '${getRegion}',
data: {
<portlet:namespace/>reg:selectednumbers
},
type : 'POST',
dataType: "text",
success : function(data) {
}
});
}
action class code
String[] organizationId = ParamUtil.getParameterValues(resourceRequest, "reg");
am getting null values . pls help some one on this.
Thank you in advance
For ajax you should be using resource requests, not action requests.
Hi
Here is example it helps you..
http://www.liferaysavvy.com/2014/01/content-auto-update-using-jquery-ajax.html
http://www.liferaysavvy.com/2014/01/content-auto-update-using-aui-ajax-in.html
Prepare JSONArray using liferay JSON API to send array of values as ajax response.
Regards,
Meera Prince
Here is example it helps you..
http://www.liferaysavvy.com/2014/01/content-auto-update-using-jquery-ajax.html
http://www.liferaysavvy.com/2014/01/content-auto-update-using-aui-ajax-in.html
Prepare JSONArray using liferay JSON API to send array of values as ajax response.
Regards,
Meera Prince
JSP:
<liferay-portlet:actionURL name="markEvent" var="markEventURL">
</liferay-portlet:actionURL>
<script>
function markAsReadURLJS(userEventId){
AUI().use('aui-io-request', function(A){
A.io.request( '<%=markEventURL%>', {
method: 'post',
data: {'<portlet:namespace/>userEventId': userEventId},
on: {
success: function() {
// console.log(this.get('responseData'));
}
}
});
});
}
</script>
JAVA:
public void markEvent(
ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
logger.debug("in markEvent");
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
WebKeys.THEME_DISPLAY);
String userNotificationEventId = ParamUtil.getString(actionRequest, "userEventId", StringPool.BLANK);
System.out.println("userEventIdin mark as read" + userEventId);
}
<liferay-portlet:actionURL name="markEvent" var="markEventURL">
</liferay-portlet:actionURL>
<script>
function markAsReadURLJS(userEventId){
AUI().use('aui-io-request', function(A){
A.io.request( '<%=markEventURL%>', {
method: 'post',
data: {'<portlet:namespace/>userEventId': userEventId},
on: {
success: function() {
// console.log(this.get('responseData'));
}
}
});
});
}
</script>
JAVA:
public void markEvent(
ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
logger.debug("in markEvent");
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
WebKeys.THEME_DISPLAY);
String userNotificationEventId = ParamUtil.getString(actionRequest, "userEventId", StringPool.BLANK);
System.out.println("userEventIdin mark as read" + userEventId);
}
Community
Company
Feedback