留言板

simple Spring portlet not working at Action mapping at liferay 6.2

bhabesh mukhopadhyay,修改在10 年前。

simple Spring portlet not working at Action mapping at liferay 6.2

New Member 帖子: 9 加入日期: 13-3-4 最近的帖子
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
There is no issue at rendering but in action the issue persists.

Appreciate any help in advance.

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

In JSP

<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>
  <tbody><tr>
    <td><form:input path="id" /></td>
  </tr>
  <tr>
    <td><form:input path="name" /></td>
  </tr>
   </tbody></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());
}


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>

	<bean id="controllerMain" class="test.controller.ControllerMain" />
	<bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
		<property name="portletModeMap">
			<map>
				<entry key="view">
					<ref bean="controllerMain" />
				</entry>
			</map>
		</property>
	</bean>



output :

someObject : 0 null null
thumbnail
meera prince,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

Liferay Legend 帖子: 1111 加入日期: 11-2-8 最近的帖子
HI


What portlet handler mapping you have used?.

try following handler.

<bean id="portletModeHandlerMapping"
class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
<property name="portletModeMap">
<map>
<entry key="view">
<ref bean="feedbackController" />
</entry>
</map>
</property>
</bean>
bhabesh bhabani mukhopadhyay,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

New Member 帖子: 9 加入日期: 13-3-4 最近的帖子
Hi meera prince,
Thanks for your help.
I tried that too but still I am getting the null value. emoticon
bhabesh bhabani mukhopadhyay,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

New Member 帖子: 9 加入日期: 13-3-4 最近的帖子
Hi prince,
Thanks for your valuable time,
I followed your advise to replace commandName with modelAttribute but the out put was still null. So I revert it back again.
I have gone through all posts you share with me. Thanks a lot for sharing. I tried to follow, even I tried on latest version of spring ( 4.0.0 and 4.0.1 [build number 628] ) but no luck till now emoticon
thumbnail
meera prince,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

Liferay Legend 帖子: 1111 加入日期: 11-2-8 最近的帖子
Hi

I will try and let you know if i success .. i will share sample portlet...

keep in touch with www.liferaysavvy.com
bhabesh bhabani mukhopadhyay,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

New Member 帖子: 9 加入日期: 13-3-4 最近的帖子
Thanks Prince,
I shall wait. It will be great to get some running sample.
thumbnail
meera prince,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

Liferay Legend 帖子: 1111 加入日期: 11-2-8 最近的帖子
Hi

I too tried to use simple spring portlet in 6.2 liferay version i have the same problem and i spend several hours... but still problem persist...

request data not able to bind with form object or command object when we use model attribute or command name... i think we need to explore more on this..

i will share once i find....


Regards,

Meera Prince
bhabesh bhabani mukhopadhyay,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

New Member 帖子: 9 加入日期: 13-3-4 最近的帖子
Thanks a lot again for your time.
I found some committed issues, but not sure whether it relates with this

https://jira.springsource.org/browse/SPR-10382
and
https://github.com/spring-projects/spring-framework/commit/9c157ea073054ef613d72d2939dbd3802649636f

After seeing these issues, I downloaded spring 4.0.1 (build number 628) but no luck.
bhabesh bhabani mukhopadhyay,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

New Member 帖子: 9 加入日期: 13-3-4 最近的帖子
Hi Prince,
Did you find any solution ..
thumbnail
meera prince,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

Liferay Legend 帖子: 1111 加入日期: 11-2-8 最近的帖子
Hi

Sorry i did not work on that these days....

sorry if i find i will post ok....

Regards,

Meera Prince
thumbnail
meera prince,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2 (答复)

Liferay Legend 帖子: 1111 加入日期: 11-2-8 最近的帖子
Hi

The following post discussed about spring problem in liferay 6.2 .

go through it it may help

https://www.liferay.com/community/forums/-/message_boards/message/32687451
thumbnail
meera prince,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2 (答复)

Liferay Legend 帖子: 1111 加入日期: 11-2-8 最近的帖子
Hi
I have used following tag in liferay-portlet.xml file its working successfully..

<requires-namespaced-parameters>false</requires-namespaced-parameters>

liferay-portlet.xml as follows

<portlet>
<portlet-name>welcome</portlet-name>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
</portlet>
bhabesh bhabani mukhopadhyay,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

New Member 帖子: 9 加入日期: 13-3-4 最近的帖子
Hi Prince,
Thanks a lot for your effort and your valuable time.
You did a great job.
It's functional now.
Once again .. THANKS A LOT ..
regards -- Bhabesh
thumbnail
Juan Gonzalez,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

Liferay Legend 帖子: 3089 加入日期: 08-10-28 最近的帖子
Hi bhabesh,

it's usually a good practice to first take a look at some of the samples you can find in liferay-plugins in github.com (6.2.x branch):

https://github.com/liferay/liferay-plugins/blob/6.2.x/portlets/sample-spring-portlet/docroot/WEB-INF/liferay-portlet.xml
thumbnail
Arshith P,修改在9 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

New Member 帖子: 2 加入日期: 14-5-21 最近的帖子
Meera Prince:
Hi
I have used following tag in liferay-portlet.xml file its working successfully..

<requires-namespaced-parameters>false</requires-namespaced-parameters>

liferay-portlet.xml as follows

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


Thank you Meera Prince for the finding. It really helped.
Also one thing I noticed is,
there is an order in which these properties are to be set inside the <portlet> tag. if not we may get error.

The content of element type "portlet" must match "(portlet-name,icon?,virtual-path?,struts-path?,parent-struts-path?,configuration-path?,configuration-action-class?,indexer-class*,open-search-class?,scheduler-entry*,portlet-url-class?,friendly-url-mapper-class?,friendly-url-mapping?,friendly-url-routes?,url-encoder-class?,portlet-data-handler-class?,staged-model-data-handler-class*,template-handler?,portlet-layout-listener-class?,poller-processor-class?,pop-message-listener-class?,social-activity-interpreter-class*,social-request-interpreter-class?,user-notification-definitions?,user-notification-handler-class*,webdav-storage-token?,webdav-storage-class?,xml-rpc-method-class?,control-panel-entry-category?,control-panel-entry-weight?,control-panel-entry-class?,asset-renderer-factory*,atom-collection adapter*,custom-attributes-display*,ddm-display?,permission-propagator?,trash-handler*,workflow-handler*,preferences-company-wide?,preferences-unique-per- layout?,preferences-owned-by-group?,use-default-template?,show-portlet-access-denied?,show-portlet-inactive?,action-url-redirect?,restore-current-view?,maximize- edit?,maximize-help?,pop-up-print?,layout-cacheable?,instanceable?,remoteable?,scopeable?,user-principal-strategy?,private-request-attributes?,private-session- attributes?,autopropagated-parameters?,requires-namespaced-parameters?,action-timeout?,render-timeout?,render-weight?,ajaxable?,header-portal-css*,header- portlet-css*,header-portal-javascript*,header-portlet-javascript*,footer-portal-css*,footer-portlet-css*,footer-portal-javascript*,footer-portlet-javascript*,css-class- wrapper?,facebook-integration?,add-default-resource?,system?,active?,include?)".

that defines the order that should be followed.

so for a portlet defined like this :
<portlet>
<portlet-name>sample</portlet-name>
<icon>/icon.png</icon>
<header-portlet-css>/css/main.css</header-portlet-css>
<footer-portlet-javascript>/js/main.js</footer-portlet-javascript>
<css-class-wrapper>sample-portlet</css-class-wrapper>
</portlet>


you should put your "requires-namespaced-parameters" tag after the <icon> tag:

<portlet>
<portlet-name>sample</portlet-name>
<icon>/icon.png</icon>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
<header-portlet-css>/css/main.css</header-portlet-css>
<footer-portlet-javascript>/js/main.js</footer-portlet-javascript>
<css-class-wrapper>sample-portlet</css-class-wrapper>
</portlet>
thumbnail
Sujay Kumar Paul,修改在9 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

Regular Member 帖子: 164 加入日期: 11-10-28 最近的帖子
Thanks Meera,

Your post is very useful for me.

It solved my problem.
Traolly Xiong,修改在9 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

Regular Member 帖子: 195 加入日期: 11-12-30 最近的帖子
Even after doing that I am still getting this error:

Class method:

@RenderMapping
public String homeGSASearch(RenderRequest request, RenderResponse response,
ModelMap modelMap)

........


liferay-portlet.xml:

<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd">

<liferay-portlet-app>
<portlet>
<portlet-name>portal-portlet-gsa</portlet-name>
<icon>/icon.png</icon>
<instanceable>false</instanceable>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
</portlet>
<portlet>
<portlet-name>gsa_save_search</portlet-name>
<icon>/icon.png</icon>
<instanceable>false</instanceable>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
<css-class-wrapper>gsa_save_search-portlet</css-class-wrapper>
</portlet>
<role-mapper>
<role-name>administrator</role-name>
<role-link>Administrator</role-link>
</role-mapper>
<role-mapper>
<role-name>guest</role-name>
<role-link>Guest</role-link>
</role-mapper>
<role-mapper>
<role-name>power-user</role-name>
<role-link>Power User</role-link>
</role-mapper>
<role-mapper>
<role-name>user</role-name>
<role-link>User</role-link>
</role-mapper>
</liferay-portlet-app>



Error:

18:08:29,014 ERROR [http-bio-80-exec-55][PortletServlet:116] javax.portlet.PortletException: Request processing failed
javax.portlet.PortletException: Request processing failed
at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:545)
at org.springframework.web.portlet.FrameworkPortlet.doDispatch(FrameworkPortlet.java:471)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:103)
at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:55)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:112)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

..............................


at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at com.gsa.portal.portlet.controller.GSASearchController.homeGSASearch(GSASearchController.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

Any thoughts on what I can try to resolve this in Liferay 6.2?
thumbnail
meera prince,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

Liferay Legend 帖子: 1111 加入日期: 11-2-8 最近的帖子
Hi All

Go through following link to get spring portlet

https://www.liferay.com/community/forums/-/message_boards/message/32699173

Regards,
Meera Prince
thumbnail
Jaydip Lakhatariya,修改在10 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

Junior Member 帖子: 53 加入日期: 13-4-18 最近的帖子
I got solution for not passing form data to spring mvc controller

Just simply add following line in liferay-portlet.xml
<portlet>
<portlet-name>{Name of portlet}</portlet-name>
<icon>{icon}</icon>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
<header-portlet-css>{your css file}</header-portlet-css>
<footer-portlet-javascript>{your js file}</footer-portlet-javascript>
</portlet>

It works :-)
Thanx.
thumbnail
Meera Prince,修改在9 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

Liferay Legend 帖子: 1111 加入日期: 11-2-8 最近的帖子
Traolly Xiong,修改在9 年前。

RE: simple Spring portlet not working at Action mapping at liferay 6.2

Regular Member 帖子: 195 加入日期: 11-12-30 最近的帖子
6.2 upgrade just gave me some different problems. The namespace helped of course. Other xml files were changed and checked out new, built and deployed as expected. The action mapping is working as expected for the spring portlet although I couldn't pin point exactly what resolved the issue.