Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:23:31+00:00 2026-06-11T17:23:31+00:00

I made a NotificationHandler class, this class contains a static List. To allow access

  • 0

I made a NotificationHandler class, this class contains a static List.
To allow access to this list I made a SessionScopped bean with a getter returning this list.

My problem is the following :

I’m on page A, I put a notification in the list, page A is regenerated, the notification is being displayed.

Then I click on a link in page A sending me to page B.

In page B there is a constructor wich destroy the list.
However the JSF page display the notification BEFORE calling the constructor.

I end up on page B with a notification for page A

Notification handler:

package com.cog.util;

import java.util.ArrayList;
import java.util.List;

public class NotificationHandler {

private static List<Notification2> listeDeNotification = new ArrayList<Notification2>();

public static void flushNotification(){
    listeDeNotification.clear();
}

public static void raiseNotification(NotificationColor color, String code){
    listeDeNotification.add(new Notification2(color.toString(), code));
}

public static void raiseNotification(NotificationColor color, String code, String additionalMessage){
    listeDeNotification.add(new Notification2(color.toString(), code, additionalMessage));
}

public static void addAdditionalMessage(String code, String additionalMessage){
    for(Notification2 n : listeDeNotification){
        if (n.getCode().equals(code)){
            n.setAdditionalMessage(additionalMessage);
        }
    }
}

public static Integer getNotificationNumber(){
    return listeDeNotification.size();
}

public static List<Notification2> getListeDeNotification(){
    return listeDeNotification;
}

}

notificationPrinter.xhtml

<composite:interface>
    <composite:attribute name="liste" />
    <composite:attribute name="locale" />
</composite:interface>

<composite:implementation>
    <ui:repeat value="#{cc.attrs.liste}" varStatus="status" var="l">
        <h:panelGrid width="100%" columns="1">
            <div id="alert" class="alert #{l.color}">
                <button class="close" data-dismiss="alert" type="button">×</button>
                <span class="rt">#{cc.attrs.locale[l.code]} #{l.additionalMessage}</span>
            </div>
        </h:panelGrid>
    </ui:repeat>
</composite:implementation>

AccessorBean

package com.cog.web.beans.util;

import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import com.cog.util.Notification2;
import com.cog.util.NotificationHandler;


@ManagedBean(name = "notificationAccessor")
@SessionScoped
public class NotificationAccessorBean {

    public List<Notification2> getNotificationList(){
        return NotificationHandler.getListeDeNotification();
    }

}

and this is what I put in jsf

problem is I want to flush the notification list betwen some pages only.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:23:32+00:00Added an answer on June 11, 2026 at 5:23 pm

    Since you are using JSF you can use its advantages (h:commandLink for example) , you can also might use the preRenderView try placing it in your page and use its listener to flush the list

    take a look at the following explanation/example JSF 2 PreRenderViewEvent example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Made a fiddle for this: http://jsfiddle.net/terjeto/MN4FJ/ My problem is that dragleave fires when you
I made the following method for creating interface instance. static IFBIndexItem* CreateFBIndexItemPtr() { IFBIndexItemPtr
I made this server class that starts a thread when new connection comes in.
I made a class for DB connection like this: public class DbHelper : IDisposable
Made this nice little loop for hiding and showing div's, works as a charm
Made a new project, added main.cpp and wrote the code at this URL: http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/example/echo/async_tcp_echo_server.cpp
made a menu out of the following code but the original href in the
I made a sweet system update feature for this game I'm making here is
Made this custom alert box: <script type="text/javascript"> $(function () { var $alert = $('#alert');
Made this script to crawl certain links on a forum and extract the username,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.