Forums de discussion

Overriding Struts Action using hook

Krishnabalaji Ramalingam, modifié il y a 11 années.

Overriding Struts Action using hook

New Member Publications: 7 Date d'inscription: 19/05/12 Publications récentes
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, modifié il y a 11 années.

RE: Overriding Struts Action using hook

Liferay Master Publications: 875 Date d'inscription: 07/01/11 Publications récentes
Could you please try by extending BaseStrutsPortletAction instead of BaseStrutsAction ..
Krishnabalaji Ramalingam, modifié il y a 11 années.

RE: Overriding Struts Action using hook

New Member Publications: 7 Date d'inscription: 19/05/12 Publications récentes
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, modifié il y a 11 années.

RE: Overriding Struts Action using hook (Réponse)

New Member Publications: 7 Date d'inscription: 19/05/12 Publications récentes
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, modifié il y a 11 années.

RE: Overriding Struts Action using hook

New Member Publications: 14 Date d'inscription: 26/06/12 Publications récentes
Hi Krishnabalaji,

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

Regards,

Hashim
thumbnail
Amit Doshi, modifié il y a 11 années.

RE: Overriding Struts Action using hook

Liferay Master Publications: 550 Date d'inscription: 29/12/10 Publications récentes
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