Search code examples
liferay-6alloy-ui

how to capture the data sent by alloy ui io request in serveresource method?


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'); 
        });

Solution

  • AUI's io request is ajax request only.

    You can get parameters in serveResource method using code below:

    ParamUtil.get(resourceRequest, "NAMEOFPARAMETER");
    

    Modify your javascript function and provide data attribute as below:

     data: {
           '<portlet:namespace />title': title,
           '<portlet:namespace />description': description,
           }