How to debug error "No render mappings found for MVC render command name"

460 views Asked by At

I'm develpoping a module for my Liferay DXP and I'm struggeling with calling my renderCommands.

Following error message occurs on the initial render and whenever I try to click a link to my RenderCommand:

No render mappings found for MVC render command name "/document-management/document/edit" for portlet com_company_tools_manager_documents_web_portlet_DocumentsPortlet

I have my "view.jsp" which contains the inclusion of my "init.jsp", creation of renderURL and the link:

<%@ include file="./init.jsp" %>
    
    <portlet:renderURL var="editDocumentURL">
        <portlet:param name="mvcRenderCommandName" value="<%=MVCCommandNames.EDIT_DOCUMENT %>" ></portlet:param>
    </portlet:renderURL>
    
<a href="${ editDocumentURL }">edit documents</a>

The "MVCCommandNames.EDIT_DOCUMENT" refers to MVCCommandNames.java:

package com.company.tools.manager.documents.web.constants;

public class MVCCommandNames {
    public static final String EDIT_DOCUMENT= "/document-management/document/edit"; }

I'm including the file in the "init.jsp" like so:

<%@ page
    import="com.company.tools.manager.documents.web.constants.MVCCommandNames"%>

Finally, I have this "EditDocumentMVCRenderCommand.java" which should be seen as a component and be connected to the link:

package com.company.tools.manager.documents.web.portlet.action;
import com.company.tools.manager.documents.web.constants.DocumentsPortletKeys;
import com.company.tools.manager.documents.web.constants.MVCCommandNames;
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCRenderCommand;
import org.osgi.service.component.annotations.Component;

@Component(immediate = true, property = { "javax.portlet.name=" + DocumentsPortletKeys.DOCUMENTS,
        "mvc.command.name=" + MVCCommandNames.EDIT_DOCUMENT}, service = MVCRenderCommand.class)
public class EditDocumentMVCRenderCommand implements MVCRenderCommand { (...) }

The portlets name which is called by "DocumentsPortletKeys.DOCUMENTS" is defined by

package com.company.tools.manager.documents.web.constants;

public class DocumentsPortletKeys {

    public static final String DOCUMENTS= "com_company_tools_manager_documents_web_portlet_DocumentsPortlet";
}

Did I forget to connect some things? How can I find out which URL the "EditDocumentMVCRenderCommand.java" listens to? Any other suggestions on how to approach this issue?

Greetings

2

There are 2 answers

0
alfilAR On

I had the same issue and solved it by creating a new mvc module only with the minimum amount of code (include only the files you are sharing in this post), and try to focus on making the render mapping work. Also, if you can share your DocumentsPortlet.java to verify the "javax.portlet.name" property is correct.

0
bui vy On

"No render mappings found for MVC render command name" indicates that there is no JSP file that represents the render command.

Well to use MVC render commands, you need these things:

  • An implementation of the MVCRenderCommand interface.
  • A portlet render URL in your view layer.
  • a Component that publishes the MVCRenderCommand service, with two properties

In your case, you are missing a "render" jsp file. In your EditDocumentMVCRenderCommand, it should be implemented something like this:

@Override
public String render(
    RenderRequest renderRequest, RenderResponse renderResponse) {

    return "/edit/document.jsp";
}

And you should have the "/edit/document.jsp" available to your path otherwise it will throw the error that you are experiencing.