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 6898293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:16:40+00:00 2026-05-27T07:16:40+00:00

There is a JSF 1.2 page with <rich:messages> and <a4j:poll> components on it. When

  • 0

There is a JSF 1.2 page with <rich:messages> and <a4j:poll> components on it. When a message is placed in FacesContext it is only shown briefly, until the poll sends the next request. Is it possible to preserve messages across AJAX requests?

  • 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-05-27T07:16:40+00:00Added an answer on May 27, 2026 at 7:16 am

    Add the following to your facelets:

    <ui:define name="metadata">
      <f:event type="preRenderView" listener="#{ajaxBacking.displayMessages}" />
    </ui:define>
    

    Create a backing bean to persist the messages through ajax calls:

    @ManagedBean
    @ViewScoped
    public class AjaxBacking {
    
    Map<String, List<FacesMessage>> messages;
    
    public AjaxBacking(){
        messages = new HashMap<String, List<FacesMessage>>();
    }
    
    public static AjaxBacking getCurrentInstance() {
        AjaxBacking ajaxBacking = null;
        FacesContext context = FacesContext.getCurrentInstance();
        if ((ajaxBacking = (AjaxBacking) context.getViewRoot().getViewMap().get("ajaxBacking")) == null){
            ajaxBacking = (AjaxBacking)context.getApplication().evaluateExpressionGet(context,"#{ajaxBacking}",AjaxBacking.class);
        }
        return ajaxBacking;
    }
    
    public void displayMessages(){
        FacesContext facesContext = FacesContext.getCurrentInstance();
        for (String component : messages.keySet()){
            for (FacesMessage message : messages.get(component)) {
                if (!facesContext.getMessageList(component).contains(message)){
                    facesContext.addMessage(component, message);
                }
            }
        }
    }
    
    public void putMessages(String component, List<FacesMessage> facesMessage){
        List<FacesMessage> messages = new ArrayList<FacesMessage>();
        for (FacesMessage message : facesMessage) messages.add(message);
        this.messages.put(component, messages);
    }
    
    public Map<String, List<FacesMessage>> getMessages() {
        return messages;
    }
    }
    

    And finally add this line to the bottom of any bean method that adds a FacesMessage.

    AjaxBacking.getCurrentInstance().putMessages(messages,facesContext.getMessageList(messages);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to execute a JSF managed bean action when a page
if there is no data to display, jsf data table shows headers only. How
I am getting the below messages when my JSF page gets rendered. The page
Imagine a JSF page with several components such as <h:selectOneMenu> , <h:dataTable> , <h:panelGrid>
I have a JSP page in a JSF application which uses A4J. I want
there's a jsf page with a form: .... <h:form> <h:commandLink action=#{userBean.logout} value=Logout /> </h:form>
Is there a way to make a progess/loading bar while a JSF page is
I'm trying to implement this simple example in JSF: There is a user.xhtml page
Good morning all. Is there any jsf control that escapes the html tags? Imagine
Are there any production quality JSF 2 implementations yet? If so what are they?

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.