Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-46371

Nested portlet and Ajax: Reject process action for xxx on zzzz

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Inactive
    • Affects Version/s: 6.2.0 CE RC5
    • Fix Version/s: 6.2.0 CE GA1
    • Component/s: Portal Services
    • Labels:
      None

      Description

      Dear all,
      I'm getting "Reject process action" message and I cannot process my ajax function in my nested portlet.
      I tried several things according to the advises of this thread https://www.liferay.com/community/forums/-/message_boards/message/37102728 :

      • add <add-default-resource>true</add-default-resource> to my liferay-portlet.xml
      • portlet.add.default.resource.check.enabled=false in portal-ext.properties
      • add portletId to the portlet.add.default.resource.check.whitelist property in portal-ext.properties

      Other guys in the above thread also tried these advises, but problem is still there.

      My Ajax code properly works with Liferay 6.1.2.

      I suppose it's a bug.

      My code:
      I embed my portlet with this code:

      	public static String renderPortlet(final PortletRequest request, final PortletResponse response,
      			final String portletId, final String queryString) throws SystemException, IOException, ServletException,
      			ValidatorException, PortletContainerException {
      		// Get servlet request / response
      		HttpServletRequest servletRequest = PortalUtil.getOriginalServletRequest(PortalUtil
      				.getHttpServletRequest(request));
      		HttpServletResponse servletResponse = PortalUtil.getHttpServletResponse(response);
      		// Get theme display
      		final ThemeDisplay themeDisplay = (ThemeDisplay) servletRequest.getAttribute(WebKeys.THEME_DISPLAY);
      		// Backup current state
      		PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
      		PortletDisplay portletDisplayClone = new PortletDisplay();
      		portletDisplay.copyTo(portletDisplayClone);
      		final Map<String, Object> requestAttributeBackup = new HashMap<String, Object>();
      		for (final String key : Collections.list((Enumeration<String>) servletRequest.getAttributeNames())) {
      			requestAttributeBackup.put(key, servletRequest.getAttribute(key));
      		}
      		// Render the portlet as a runtime portlet
      		String result = "";
      		try {
      			com.liferay.portal.model.Portlet portlet = PortletLocalServiceUtil.getPortletById(
      					PortalUtil.getCompanyId(request), portletId);
      			portlet.setRenderWeight(0);
      			servletRequest.setAttribute(WebKeys.RENDER_PORTLET_RESOURCE, Boolean.TRUE);
      			String columnId = null;
      			Integer columnPos = null;
      			Integer columnCount = null;
      			try {
      				themeDisplay.setAjax(true);
      				String ajaxId = request.getParameter("ajax_id");
      				if (ajaxId != null) {
      					servletResponse.setHeader("Ajax-ID", ajaxId);
      				}
      				servletRequest = PortletContainerUtil.setupOptionalRenderParameters(
      						servletRequest, null, columnId, columnPos, columnCount);
      				PortletContainerUtil.render(servletRequest, servletResponse, portlet);
      //				StringBundler _result = render(portlet, columnId, columnCount, columnPos, servletRequest, servletResponse);
      //				result = _result.toString(true);
      				
      			} catch (Exception e) {
      				LOGGER.error("Cannot render the embedded portlet", e);
      			}
      		} finally {
      			// Restore the state
      			portletDisplay.copyFrom(portletDisplayClone);
      			portletDisplayClone.recycle();
      			for (final String key : Collections.list((Enumeration<String>) servletRequest.getAttributeNames())) {
      				if (!requestAttributeBackup.containsKey(key)) {
      					servletRequest.removeAttribute(key);
      				}
      			}
      			for (final Map.Entry<String, Object> entry : requestAttributeBackup.entrySet()) {
      				servletRequest.setAttribute(entry.getKey(), entry.getValue());
      			}
      		}
      		return result;
      	}
      

      my jsp:

      <portlet:actionURL name="fakeOp" var="selectURL" />
      
      <aui:script>
      Liferay.provide(
      	window,
      	'<portlet:namespace />fakeOp',
      	function() {
      		var A = AUI();
      			var url = '<%= selectURL.toString() %>';
      			var gw = A.one('#<portlet:namespace />gws');
      			A.io.request(
      				url,
      				{
      					//data to be sent to server
      					data: {
      						<portlet:namespace />test: gw.val()
      					},
      					dataType: 'json',
      
      					on: {
      						failure: function() {
      							...
      						},
      						success: function(event, id, obj) {
      							...
      						}
      				}
      			}
      		); //END of io Request
      	},
      	['aui-io']
      ); //End of Provide
      
      </aui:script>
      
      <aui:form name="fm" action="<%= selectURL.toString() %>" method="post">
      	<aui:fieldset>
      		<div id="messageResult" style="visibility: hidden;"></div>
      
      		<aui:select id="gws" name="gws" label="Select:" helpMessage="Select here !!!!!"
      			onChange='<%= renderResponse.getNamespace() + "fakeOp();" %>'>
      			....
      		</aui:select>
      	</aui:fieldset>
      </aui:form>
      

      Nicolas.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  5 years, 26 weeks ago

                  Packages

                  Version Package
                  6.2.0 CE GA1