Fórumok

Overriding Struts Action using hook

Krishnabalaji Ramalingam, módosítva 11 év-val korábban

Overriding Struts Action using hook

New Member Bejegyzések: 7 Csatlakozás dátuma: 2012.05.19. Legújabb bejegyzések
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

<!--?xml version="1.0" encoding="UTF-8"?-->


<hook>
	<portal-properties>portal.properties</portal-properties>
	<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
	<struts-action>
		<struts-action-path>/portal/update_terms_of_use</struts-action-path>
		<struts-action-impl>com.liferay.portal.hook.action.UpdateTermsOfUseAction</struts-action-impl>
	</struts-action>
</hook>

UpdateTermsOfUseAction.java

public 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
thumbnail
Jitendra Rajput, módosítva 11 év-val korábban

RE: Overriding Struts Action using hook

Liferay Master Bejegyzések: 875 Csatlakozás dátuma: 2011.01.07. Legújabb bejegyzések
Could you please try by extending BaseStrutsPortletAction instead of BaseStrutsAction ..
Krishnabalaji Ramalingam, módosítva 11 év-val korábban

RE: Overriding Struts Action using hook

New Member Bejegyzések: 7 Csatlakozás dátuma: 2012.05.19. Legújabb bejegyzések
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, módosítva 11 év-val korábban

RE: Overriding Struts Action using hook (Válasz)

New Member Bejegyzések: 7 Csatlakozás dátuma: 2012.05.19. Legújabb bejegyzések
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


public class UpdateTermsOfUseAction extends BaseStrutsAction {

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response)	throws Exception { .. }
}


Answer :

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


public class UpdateTermsOfUseAction extends BaseStrutsAction {

public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {...}

}


Please let me know if you need further information.

Thanks,
R.Krishnabalaji
Hashim Raza, módosítva 11 év-val korábban

RE: Overriding Struts Action using hook

New Member Bejegyzések: 14 Csatlakozás dátuma: 2012.06.26. Legújabb bejegyzések
Hi Krishnabalaji,

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

Regards,

Hashim
thumbnail
Amit Doshi, módosítva 11 év-val korábban

RE: Overriding Struts Action using hook

Liferay Master Bejegyzések: 550 Csatlakozás dátuma: 2010.12.29. Legújabb bejegyzések
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