Message Boards

Session errors are not visible inside portal_normal.ftl

Nikita Laitinen, modified 2 Years ago.

Session errors are not visible inside portal_normal.ftl

Junior Member Posts: 44 Join Date: 12/18/19 Recent Posts

Hello

I use liferay 7.4 (doing migration from 7.0 to 7.4 right now)

I'm trying to get no such resource exception error inside theme (portal normal file) using staticUtil["com.liferay.portal.kernel.servlet.SessionErrors"] but i could not. This object is available but i can not print any session errors using code below
 

<#list SessionErrors.keySet(request) as item>

     <#assign exception = item[item?last_index_of(".") + 1..] >

     <#if exception?starts_with('NoSuch') && exception?ends_with('Exception') >

         my logic here

     </#if>

</#list>

(The code above works on liferay 7.0)

Could someone help me please??

Update: SessionErrors.size(request) is 0, i dont know why, i'm on 404 page seeing liferay notification - not found, it is weird

thumbnail
Olaf Kock, modified 2 Years ago.

RE: Session errors are not visible inside portal_normal.ftl

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts

The natural place for application (widget-) specific error messages to live is within that widget. Evaluation order for template vs widget is not defined, and can even happen in different HTTP Requests - so while you might have been lucky that it happened to work in a previous versions, I'd say that the approach is rather wrong and relies on random implementation details (that have obviously changed).

Please start with stating the problem that you're trying to solve. Maybe someone here can suggest a different and better solution for it.

In fact, I can't rule out a full redirect (e.g. a new request) for 404 or other error pages, that don't have any more connection to the past request.

Nikita Laitinen, modified 2 Years ago.

RE: RE: Session errors are not visible inside portal_normal.ftl

Junior Member Posts: 44 Join Date: 12/18/19 Recent Posts

I'm trying to create 404 page as I did it on 7.0 liferay.

Inside portal_normal I check session errors and in the case there is 404 i show user custom 404 web content (load web content instead of liferay content) + i hide footer that is defined inside portal_normal + i hide some other params that are defined inside head section.