Foros de discusión

PortalUtil in a hook?

thumbnail
Cameron McBride, modificado hace 12 años.

PortalUtil in a hook?

Expert Mensajes: 269 Fecha de incorporación: 8/02/11 Mensajes recientes
I am trying to create an auto login without using the ext environment. My auto login gets called just fine but no classes seem to be available to me, that are available in an ext environment.
PortalUtil.getCompany(request);


That throws a class not found exception. ParamUtil and Validator are also not accessible. Why am I unable to access these from a hook?

If I place my same class in an ext then it works fine.
thumbnail
Arvind Mishra, modificado hace 12 años.

RE: PortalUtil in a hook?

Regular Member Mensajes: 226 Fecha de incorporación: 13/02/08 Mensajes recientes
Classes only in portal-service (source code) or ext-service (in case of ext environment of ext-plugin) are available to Hooks (or any other type of Plugin).
If you could post code snippet, it will be more helpful to identify the problem.

Thanks
Arvind
thumbnail
Ravi Kumar Gupta, modificado hace 12 años.

RE: PortalUtil in a hook?

Liferay Legend Mensajes: 1302 Fecha de incorporación: 24/06/09 Mensajes recientes
Look for the alternative in portal-kernel.. that will be available.
thumbnail
Cameron McBride, modificado hace 12 años.

RE: PortalUtil in a hook?

Expert Mensajes: 269 Fecha de incorporación: 8/02/11 Mensajes recientes
What is the best way to "locate" these classes/methods? There is a com.liferay.portal.kernel.util.ParamUtil class for example. I include it and when I try to use it you get a "Could not load com.liferay.portal.kernel.util.ParamUtil" crash.

import com.liferay.portal.kernel.util.ParamUtil;
String login = ParamUtil.getString(request, getLoginParam());

Similar error when trying to use the class com.liferay.portal.kernel.util.Validator.

I also tried to get the Company using the ThemeDisplay inside my AutoLogin class but themeDisplay ends up being null.
ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
					WebKeys.THEME_DISPLAY);
			Company company = themeDisplay.getCompany();


Follow that up with my main goal of creating an AutoLogin hook instead of using an EXT plugin:
import com.liferay.portlet.login.util.LoginUtil;
LoginUtil.login(request, response, login, password, false, "screenName");

And you get the same could not import error. It seems like using a nice hook for an autologin may not be the way to go.