掲示板

Overriding Struts Action using hook

11年前 に Krishnabalaji Ramalingam によって更新されました。

Overriding Struts Action using hook

New Member 投稿: 7 参加年月日: 12/05/19 最新の投稿
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
11年前 に Jitendra Rajput によって更新されました。

RE: Overriding Struts Action using hook

Liferay Master 投稿: 875 参加年月日: 11/01/07 最新の投稿
Could you please try by extending BaseStrutsPortletAction instead of BaseStrutsAction ..
11年前 に Krishnabalaji Ramalingam によって更新されました。

RE: Overriding Struts Action using hook

New Member 投稿: 7 参加年月日: 12/05/19 最新の投稿
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
11年前 に Krishnabalaji Ramalingam によって更新されました。

RE: Overriding Struts Action using hook (回答)

New Member 投稿: 7 参加年月日: 12/05/19 最新の投稿
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
11年前 に Hashim Raza によって更新されました。

RE: Overriding Struts Action using hook

New Member 投稿: 14 参加年月日: 12/06/26 最新の投稿
Hi Krishnabalaji,

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

Regards,

Hashim
thumbnail
11年前 に Amit Doshi によって更新されました。

RE: Overriding Struts Action using hook

Liferay Master 投稿: 550 参加年月日: 10/12/29 最新の投稿
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