1
votes

A Simple portlet which is functioning properly at LifeRay 6.0 and Open Portlet Container but when I deploy to Liferay 6.2 it breaks at action mapping. I found the two issues at debugging . 1) the form data is not available (not populated) at action method 2) can not able to go to render method with parameter using setRenderParameter

Appreciate any help in advance.

Code sample as follows - not included the 2nd option (i.e setRenderParamer)

<portlet:defineObjects/>
<portlet:actionURL var="doFormActionURL">
   <portlet:param name="action" value="doFormAction" />
</portlet:actionURL>



  <form:form name="form" modelAttribute="someObject" method="post"  action="${doFormActionURL}" htmlEscape="false" >
   <table>
  <tr>
    <td><form:input path="id" /></td>
  </tr>
  <tr>
    <td><form:input path="name" /></td>
  </tr>
   </table>
<input type="submit" value="Just do it" />
 </form:form>

in controller

@Controller
@RequestMapping("VIEW")
public class ControllerMain
{

@RenderMapping
public String setModelAndView(PortletRequest request, Model model) {

    model.addAttribute("someObject", new SomeObject());
    return "home";
 }

@ActionMapping(params = "action=doFormAction")
public void doFormAction(@ModelAttribute ("someObject") SomeObject someObject, ActionRequest request) {
    String strname = request.getParameter("name");
    System.out.println("someObject : "+someObject.toString());
    System.out.println("name : "+strname);


}

In context

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <!-- property name="cache" value="true" /-->
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
    <property name="requestContextAttribute"><value>rc</value></property>
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
</bean>

output :

someObject : 0 null null name : null

Does any one try spring on liferay 6.2 . Please share your experiences

2
How did you made this portlet compatible to 6.2 version?Pankaj Kathiriya
Hi Pankaj, Thanks for your response, In development .. 1) liferay (both 6.0 and 6.2) is configured with liferay-eclipse ide so direct deployment is configured at the time of deployment 2) to export war, eclipse provide option ('Optimise server runtime') there I am providing the liferay 6.0 / 6.2 options (pre configured)bhabesh
There is no issue at rendering but in action the issue persistsbhabesh

2 Answers

3
votes

But found some changes in liferay-portlet.xml of Sample Spring portlet from the github code of Liferay plugins.

Try below changes. Set to false in your liferay-portlet.xml and try again by deploying the portlet.

<portlet>
    <portlet-name>welcome</portlet-name>
    <requires-namespaced-parameters>false</requires-namespaced-parameters>
</portlet>

Reference taken from Sample Spring Portlet code from Liferay github code. LR 6.1 - https://github.com/liferay/liferay-plugins/blob/6.1.x/portlets/sample-spring-portlet/docroot/WEB-INF/liferay-portlet.xml

LR 6.2 - https://github.com/liferay/liferay-plugins/blob/6.2.x/portlets/sample-spring-portlet/docroot/WEB-INF/liferay-portlet.xml

0
votes

You should either put a namespace prefix to your name value like this:

<input type="text" name="<portlet:namespace />inputTextName" />

or you can set the requires-namespaced-parameters setting to false in your liferay-portlet.xml.

This is a change since Liferay 6.2: https://github.com/liferay/liferay-aui-upgrade-tool/issues/30