フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
William Gosse
Overiding LoginAction
2011/12/06 7:02
答え

William Gosse

ランク: Regular Member

投稿: 108

参加年月日: 2010/07/04

最近の投稿

I want overide com.liferay.portlet.login.action.LoginAction as part of an extension project I have.

I'm not sure how to designate my custom class in the portal.properties file. Is this possible?

Actually I just wound up replacing the LoginAction with one that had the additional code that I needed, instead of extending it with a custom child class.
Amos Fong
RE: Overiding LoginAction
2011/12/06 14:26
答え

Amos Fong

LIFERAY STAFF

ランク: Liferay Legend

投稿: 1844

参加年月日: 2008/10/07

最近の投稿

Hi Bill,

You have two options. You can use ext and override just that struts action in struts-config-ext.xml.
http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/creating-an-ext-plugin

Or create an hook:
http://www.liferay.com/web/mika.koivisto/blog/-/blogs/7132115
Emilio Jose Lamas Fraga
RE: Overiding LoginAction
2012/06/07 7:33
答え

Emilio Jose Lamas Fraga

ランク: Junior Member

投稿: 42

参加年月日: 2011/11/29

最近の投稿

Hi Amos,

I don't know how to create a hook in the way Mika suggests for LoginAction; when I try to deploy, it throws a ClassNotFoundException because of the PortalAction that LoginAction extends.

I think this is because LoginAction belongs to portal-impl and it's not in the kernel package - like, for example, BaseStrutsAction -, so maybe in this case it's only possible to override LoginAction through EXT Plugin.

Am I Right? o I just making a mistake developing the hook?

Thanks!
Srikanth Konjarla
RE: Overiding LoginAction
2012/06/07 7:39
答え

Srikanth Konjarla

ランク: Junior Member

投稿: 51

参加年月日: 2008/10/24

最近の投稿

A sample to extend struts action might help.

http://svn.liferay.com/repos/public/plugins/trunk/hooks/sample-struts-action-hook/
Emilio Jose Lamas Fraga
RE: Overiding LoginAction
2012/06/07 8:47
答え

Emilio Jose Lamas Fraga

ランク: Junior Member

投稿: 42

参加年月日: 2011/11/29

最近の投稿

Hi Srikanth,

I've already try that example and it works fine. My problem is overriding the LoginAction class.

LoginAction extends com.liferay.portal.struts.PortletAction, and, when I try to deploy my ext plugin, it throws an exception because that class is not found.

Regards.
Matthew Stevenson
RE: Overiding LoginAction
2012/06/19 8:00
答え

Matthew Stevenson

ランク: New Member

投稿: 12

参加年月日: 2012/05/17

最近の投稿

Same issue experienced when trying to extend OpenIdAction in a hook:

1Caused by: java.lang.ClassNotFoundException: com.liferay.portlet.login.action.OpenIdAction
2    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
3    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
4    ... 31 more


Am using Liferay 6.1EE
Janus Godard
RE: Overiding LoginAction
2013/10/03 7:39
答え

Janus Godard

ランク: New Member

投稿: 17

参加年月日: 2013/08/01

最近の投稿

Emilio Jose Lamas Fraga:
Hi Srikanth,

I've already try that example and it works fine. My problem is overriding the LoginAction class.

LoginAction extends com.liferay.portal.struts.PortletAction, and, when I try to deploy my ext plugin, it throws an exception because that class is not found.

Regards.



Did you ever find a solution to that problem?

I'm having the same problem.

I'm working on adding captcha to the sign in page, as per:
https://www.liferay.com/community/forums/-/message_boards/message/11428960

The hook content is:
1<hook>
2    <custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
3    <struts-action>
4        <struts-action-path>/login/login</struts-action-path>
5        <struts-action-impl>com.janus.portal.hook.login.captcha.CaptchaLoginAction</struts-action-impl>
6    </struts-action>
7</hook>

The class is CaptchaLoginAction extends com.liferay.portlet.login.action.LoginAction

The error is:
13:40:28,064 ERROR [pool-2-thread-56][HotDeployImpl:191] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering hook for captcha-login-hook
[...]
Caused by: java.lang.ClassNotFoundException: com.liferay.portlet.login.action.LoginAction
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
Jose Jimenez
RE: Overiding LoginAction
2014/01/28 14:54
答え

Jose Jimenez

LIFERAY STAFF

ランク: Regular Member

投稿: 124

参加年月日: 2012/08/22

最近の投稿

Hi Janus,
The LoginAction is under the portal classloader, just in portal-impl that is unavalaible from the hook classloader: https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portlet/login/action/LoginAction.java
In a hook you only can add/replace actions but not including portal-impl dependencies.
I hope this helps you.
Jose