Foros de discusión

Is it possible to get the session errors of a portlet from a theme?

thumbnail
David García González, modificado hace 12 años.

Is it possible to get the session errors of a portlet from a theme?

Regular Member Mensajes: 127 Fecha de incorporación: 14/07/09 Mensajes recientes
Hi all,
I wanted to log a user from a velocity template for a theme and I got it! But I have a problem: If the login/password are incorrect, could I obtain the session errors of the login portlet?

This is the code of this portlet:

if (cause instanceof PasswordExpiredException || cause instanceof UserLockoutException) {
		SessionErrors.add(actionRequest, cause.getClass().getName());
}


How could I get these session variables from a velocity template? Are them in the scope of the portlet or in the scope of the application?

Thanks to everybody!
thumbnail
David García González, modificado hace 12 años.

RE: Is it possible to get the session errors of a portlet from a theme?

Regular Member Mensajes: 127 Fecha de incorporación: 14/07/09 Mensajes recientes
It is very strange because I am printing all the request and session attributes but I don't find any variable with the login error.
This is the code I'm running to show the request and session attributes:

#set ($attributeNames = $request.getAttributeNames())

#foreach($attributeName in $attributeNames)
$attributeName : $request.getAttribute($attributeName)
<br>
#end

#set($isUserLogged = $request.getAttribute('liferay-ui:error:translateMessage'))
<h1>$isUserLogged</h1>


<h1>Sesión</h1>
#set ($session = $request.getSession())
#set ($sessionNames = $session.getAttributeNames())

#foreach($sessionName in $sessionNames)
$sessionName : $session.getAttribute($sessionName)
<br>
#end
thumbnail
Jesus Alberto de los Bueis Fernández, modificado hace 12 años.

RE: Is it possible to get the session errors of a portlet from a theme?

New Member Mensajes: 16 Fecha de incorporación: 1/04/09 Mensajes recientes
The problem is you need the PortletRequest instead of HttpServletRequest. Try to get the session from a PortletRequest (if you can in your context). The only problem with the PorltetRequet is that I'm not sure you can get it in a theme without any problems.

Once, you have the PortletRequest you can get the SessionError class like this:

#set ($sessionErrors = $portal.getClass().forName("com.liferay.portal.kernel.servlet.SessionErrors"))
$sessionErrors.get($renderRequest,'com.liferay.portal.security.auth.AuthException')


I hope I've helped you
thumbnail
David García González, modificado hace 12 años.

RE: Is it possible to get the session errors of a portlet from a theme?

Regular Member Mensajes: 127 Fecha de incorporación: 14/07/09 Mensajes recientes
Thanks! As you said the problem is that I don't know how to get the portletRequest from the context of the theme.

Is this possible?