Search code examples
liferayliferay-6

Liferay MVCPortlet connect FORM actionURL with action


I'm a new user on Liferay. I'm trying to connect my form on the view.jsp:

<portlet:actionURL name="addRule" var="addRuleURL"/>
<aui:form action="<%= addRuleURL.toString() %>" method="post">
    .....

With the action in the ActionUtil.java (using Hibernate - Service Builder):

@ProcessAction(name = "addRule")
public void addRule(ActionRequest request, ActionResponse response)

But I can't, Eclipse says:

java.lang.NoSuchMethodException: com.liferay.util.bridges.mvc.MVCPortlet.addRule(javax.portlet.ActionRequest, javax.portlet.ActionResponse)

What can I do to connect my form in the correct way?


Solution

  • I think you are having this problem because you did not include your portlet in portlet.xml, so Liferay eventually uses the default MVCPortlet class which does not have the addRule method. So make sure you have something like this in portlet.xml for your custom MVC portlet:

    <portlet-name>yourmvcportlet</portlet-name>
    <display-name>Your MVC Portlet</display-name>
    <portlet-class>your.portlet.package.YourMVCPortlet</portlet-class>
    <init-param>
      <name>view-jsp</name>
      <value>/jsp/view.jsp</value>
    </init-param>