2013-12-16 41 views
1

一个在Liferay 6.0和Open Portlet Container上正常运行的简单portlet,但是当我部署到Liferay 6.2时,它会在操作映射中中断。我在调试中发现了两个问题。 1)在操作方法 上无法使用表单数据(未填充)2)无法使用setRenderParameter参数呈现方法简单的Spring Portlet不能在Liferay的Action映射中工作6.2

请提前感谢您的帮助。

代码示例如下: - 不包括在控制器

@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); 


} 

在上下文

<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> 

输出的第二选项(即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> 

someOb JECT:0 空 空 名:空

是否有任何人尝试的Liferay 6.2春天。请分享您的经验

+0

你是如何做出这个portlet到6.2版本兼容? –

+0

嗨Pankaj,感谢您的回应,正在开发中.. 1)liferay(包括6.0和6.2)都配置了liferay-eclipse IDE,因此在部署时配置了直接部署 2)导出war,eclipse提供了选项('优化服务器运行时')那里我提供了liferay 6.0/6.2选项(预配置) – bhabesh

+0

在渲染时没有问题,但在实际操作中问题依然存在 – bhabesh

回答

3

但发现Liferay插件的github代码中Sample Spring portlet的liferay-portlet.xml发生了一些变化。

请尝试以下更改。 在您的liferay-portlet.xml中设置为false,并通过部署portlet再次尝试。

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

引用来自Liferay github代码中的样本Spring Portlet代码。 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

感谢您的辛勤付出。 require-namespaced-parameters条目解决了这个问题。实际上,你和辍学生都会尝试他们的水平,并为我提供正确的解决方案。我对你们两个人都有同等的尊重,但由于你的回答早于辍学,我将其标记为答案。 – bhabesh

+0

保存了我的一天问题:-) –

0

您应该把一个命名空间前缀为您name值是这样的:

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

,或者你可以设置requires-namespaced-parameters设置为false您liferay-portlet.xml

这是因为Liferay的6.2的变化:https://github.com/liferay/liferay-aui-upgrade-tool/issues/30

+0

谢谢你的辍学为你的宝贵贡献。我认为将表单元素级别的命名空间很累,但是可以使用liferay-portlet.xml – bhabesh

相关问题