Message Boards

Duplicated success alert from StrutsAction

Václav Suchánek, modified 3 Years ago.

Duplicated success alert from StrutsAction

Junior Member Posts: 26 Join Date: 8/15/18 Recent Posts
Hello,

I have following scenario:
I have created a custom module where I applied StrutsAction:

@Component(
        immediate = true, property = "path=/portal/customModule/find_entry",
        service = StrutsAction.class
)
public class FindEntryAction extends FindStrutsAction {...}

Inside of it I'm overriding:

@Override
public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
    SessionMessages.add(request, "request_processed", "test");

    super.execute(request, response);

    return null;
}

And If i redeploy module and render it so the result is following:



Alert Message is displayed six times. This number (6) is related to the number of rendered portlets on the page - for every portlet layout is this message rendered. I did some tests and if I remove one portlet from the page so there will be only 5 these messages rendered and so on.

It looks like a bug for me. But maybe I missed something.

Is there any other way how to add message to SessionMessages? Can I add some namespace or portlet id?

Expected Result:
Alert is displayed only once.
Actual Result:
Alert is displayed six times.

Tested on:
Liferay 7.3.4 GA5 (https://releases-cdn.liferay.com/portal/7.3.4-ga5/liferay-ce-portal-tomcat-7.3.4-ga5-20200811154319029.tar.gz)
Server version: Apache Tomcat/9.0.33
OS Name: Windows 10
JVM Version: 1.8.0_144-b01
PostgreSQL
Maven workspace
IDE: IntelliJ IDEA 2020.2 (Ultimate Edition) Build #IU-202.6397.94, built on July 27, 2020

Thanks in advance.

Vaclav