Getting blank values for title and description in serveResource method.Is this the right way to send the parameters from io request?
After inserting blank values in database I have to reload the page to see the inserted values?So io-request is not ajax request?
<aui:script use="aui-base">
A.one('#<portlet:namespace/>save').on('click', function(event) {
var A = AUI();
var title=A.one('#<portlet:namespace/>title').val();
alert(title);
var description=A.one('#<portlet:namespace/>description');
var url = '<%= newJob.toString() %>';
A.io.request(
url,
{
method:'POST',
data: {
<portlet:namespace />title: title,
<portlet:namespace />description: description,
},
}
['aui-io-deprecated']
);
Liferay.Util.getOpener().<portlet:namespace/>closePopup('<portlet:namespace/>dialog');
});
AUI's io request is ajax request only.
You can get parameters in serveResource method using code below:
Modify your javascript function and provide data attribute as below:
I assume both
title
anddescription
are textfields. If so,description
is missing a.val()
call, or more appropriately,.get('value')
. I didn't use a dialog/modal in my source, but the overall approach should be the same.I'm still relatively new to Liferay and have had trouble with this as well. I've noticed that the
data
parameters are not in theparametersMap
of the defaultResourceRequest
, as you have stated. Out of curiosity, I decided to usein the
serveResource
method and check it'sparametersMap
. Thetitle
anddescription
parameters are available therein. I'm still learning where and how to access data from Liferay objects, but it would seem that for theUploadPortletRequest
to have the data, it would be plucked from somewhere within the defaultResourceRequest
... where still remains elusive to me.After inserting blank values in database I have to reload the page to see the inserted values?
You have to reload the page because a
resource
action does not trigger a page refresh. If you are manipulating data that you want reflected in some other "view" you'll need to configure the appropriate communication or use one of the other available url types that does trigger thedoView
method of your other "view".