Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Krishnabalaji Ramalingam
Overriding Struts Action using hook
July 11, 2012 1:58 AM
Answer

Krishnabalaji Ramalingam

Rank: New Member

Posts: 7

Join Date: May 18, 2012

Recent Posts

Hello,

Version : Liferay EE 6.0 SP2
Business case: Override the terms of use according to the login user role

I am trying to override the UpdateTermsOfUseAction class using liferay hook as per the blogs : http://www.liferay.com/web/mika.koivisto/blog/-/blogs/7132115

But I am getting ClassCastException

liferay-hook.xml
 1
 2<?xml version="1.0" encoding="UTF-8"?>
 3<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.0.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_0_0.dtd">
 4
 5<hook>
 6    <portal-properties>portal.properties</portal-properties>
 7    <custom-jsp-dir>/custom_jsps</custom-jsp-dir>
 8    <struts-action>
 9        <struts-action-path>/portal/update_terms_of_use</struts-action-path>
10        <struts-action-impl>com.liferay.portal.hook.action.UpdateTermsOfUseAction</struts-action-impl>
11    </struts-action>
12</hook>

UpdateTermsOfUseAction.java
1
2public class UpdateTermsOfUseAction extends BaseStrutsAction {... }

As per the message board http://www.liferay.com/community/forums/-/message_boards/message/13487363, Prefer EXT plugin.

Could you please update us to achieve this implementation using hook ?

Thanks in Advance

Regards,
R.Krishnabalaji
Jitendra Rajput
RE: Overriding Struts Action using hook
July 11, 2012 10:53 PM
Answer

Jitendra Rajput

Rank: Liferay Master

Posts: 858

Join Date: January 7, 2011

Recent Posts

Could you please try by extending BaseStrutsPortletAction instead of BaseStrutsAction ..
Hashim Raza
RE: Overriding Struts Action using hook
July 11, 2012 11:30 PM
Answer

Hashim Raza

Rank: New Member

Posts: 14

Join Date: June 25, 2012

Recent Posts

Hi Krishnabalaji,

Can you please post your exception stack trace? First few lines will do. Thanks.

Regards,

Hashim
Amit Doshi
RE: Overriding Struts Action using hook
July 12, 2012 12:10 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 549

Join Date: December 29, 2010

Recent Posts

Hi Krishnabalaji,

Please check below link, which will be helpful for creating struts action Hook in liferay.

http://www.liferay.com/web/mika.koivisto/blog/-/blogs/7132115

Thanks & Regards,
Amit Doshi
Krishnabalaji Ramalingam
RE: Overriding Struts Action using hook
July 12, 2012 10:12 PM
Answer

Krishnabalaji Ramalingam

Rank: New Member

Posts: 7

Join Date: May 18, 2012

Recent Posts

Hi,

Thank you for your response

I am getting the exception, as mentioned in the below link
http://www.liferay.com/community/forums/-/message_boards/message/13487363,

Regards,
R.Krishnabalaji
Krishnabalaji Ramalingam
RE: Overriding Struts Action using hook
July 17, 2012 1:51 AM
Answer

Krishnabalaji Ramalingam

Rank: New Member

Posts: 7

Join Date: May 18, 2012

Recent Posts

Hi All,

Thank you for your response.

I have implemented my business case in hook itself. I did a mistake. In my previous code I have used the below snippet

1
2public class UpdateTermsOfUseAction extends BaseStrutsAction {
3
4public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
5            HttpServletResponse response)    throws Exception { .. }
6}


Answer :

We need to use execute(HttpServletRequest request, HttpServletResponse response) or
execute(StrutsAction originalStrutsAction, HttpServletRequest request, HttpServletResponse response)

1
2public class UpdateTermsOfUseAction extends BaseStrutsAction {
3
4public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {...}
5
6}


Please let me know if you need further information.

Thanks,
R.Krishnabalaji