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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:29:47+00:00 2026-05-25T19:29:47+00:00

I have a problem. I need to know whether my page has global errors

  • 0

I have a problem. I need to know whether my page has global errors or not. This is because I have 2 different h:messages (error containers)

<h:messages id="errorMsgsContainer"
layout="table" 
rendered="true"
styleClass="message-container error-message" 
infoClass="info" 
errorClass=" error" warnClass="warn-message warn" globalOnly="true"/>

<h:messages id="errorMsgsContainerValidation"
layout="table" 
styleClass="message-container error-message-validation" 
infoClass="info" 
errorClass="error" globalOnly="false"/>

One will show the business related messages and the other will just show the validation messages. There are two messages because of business requirements.

When validation error messages are produced, the facelet works fine, because one of the messages tag has the globalOnly="true" attribute-value pair.

The problem comes when I’ve a global-only error. It will appear in both boxes.

I want to know if any of there errors are global, so I don’t show the validation container till the global errors are fixed by the user on my form.

I’ve tried to get it through the FacesContext with

FacesContext.getCurrentInstance().getMessageList().get(i).getSeverity()

and some other commands but it does not seem to work.

Please help me to solve this problem. How can I get the current global messages list, so I can know if there is any global error?

  • 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-25T19:29:47+00:00Added an answer on May 25, 2026 at 7:29 pm

    When validation error messages are produced, the facelet works fine, because one of the messages tag has the globalOnly=”true” attribute-value pair.

    This is incorrect. You are seeing messages for validation errors, in the other h:messages tag with the globalOnly="false" attribute-value pair. Validation messages always have a client Id, which happens to be the Id of the form element that failed validation, and hence will be displayed in a messages tag that allows non-global messages to be displayed, or has the value of the for attribute set to the applicable Id.

    The problem comes when I’ve a global-only error. It will appear in both boxes.

    This is expected behavior. I believe you’ve confused the meaning of the globalOnly attribute. When the value of the globalOnly attribute is true, only global messages (i.e. messages without a client Id) will be displayed; when the value is false, global messages will be displayed in addition to other messages that are already queued. This would explain why global messages are displayed twice – the first h:messages tag would display the global message because it should display only global messages, and the second would display it because it can display it.

    Please help me to solve this problem. How can I get the current global messages list, so I can know if there is any global error?

    If you want to continue having two h:messages tags in your facelet, then you can use a “pseudo-global” Id when queuing your FacesMessages for display, instead of specifying an Id of null; the value of the pseudo-global Id in the following example is inputForm which is a valid client Id (of the form) that would not have any validation messages produced in this case:

    FacesContext.getCurrentInstance().addMessage("inputForm", new FacesMessage(FacesMessage.SEVERITY_INFO, "Added a global message", null));
    

    You can then add a EL expression to render the messages tag responsible for display of the input-validation messages:

    <html xmlns="http://www.w3.org/1999/xhtml" 
          xmlns:ui="http://java.sun.com/jsf/facelets" 
          xmlns:h="http://java.sun.com/jsf/html" 
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:fn="http://java.sun.com/jsp/jstl/functions">
    ...
        <h:form id="inputForm">
        ...
        </h:form>
        <h:messages id="psuedoGlobalMessages" for="inputForm" globalOnly="true" infoStyle="color:green" errorStyle="color:red" warnClass="color:orange" />
        <h:messages id="clientMessages" rendered="#{fn:length(facesContext.getMessageList('inputForm')) == 0}" globalOnly="false" infoStyle="color:green" errorStyle="color:red" warnClass="color:orange" />
    ...
    

    Note, the use of the globalOnly attribute in only one messages tag. The same messages tag is also not displayed if a pseudo-global message is queued up for display via the EL expression specified in the rendered attribute. You can also use the client Id of a hidden form element created specifically to direct all pseudo-global messages, instead of the form’s client Id.

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

Sidebar

Related Questions

I need to know whether the following problem has been studied before: Let's have
I have solved this problem, I just need to know what to do. I
I have this problem where I need to design a Java package which is
I have the following problem: We need to find the next august. I other
I have a problem where I need to remove all code and triggers from
I have the following problem: I need to use XSLFO to generate a 2-column
I have the next problem: I need to process only 1 request at a
I have a problem where I always need to give simple access to my
I have a problem. I need to host grid with controls in ScrollViewer to
I have a problem. I need to trace all read/write operations to the registry

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.