2013-12-16 44 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

相關問題