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

  • SEARCH
  • Home
  • 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 3398376
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:38:31+00:00 2026-05-18T04:38:31+00:00

I’m currently learning about jsf 2.0 from core jsf 2.0 book + glassfish +

  • 0

I’m currently learning about jsf 2.0 from core jsf 2.0 book + glassfish + cdi.

I would like to ask a question about handling validations that are not defined in the jsf pages or managed/named beans with bean-validation-framework.
I got these tiers in my head :

  • 1) ui tier / jsf pages
  • 1.5) jsf managed / named beans (i use 1.5, because i think it’s still tightly coupled with the jsf tier, like the backing beans)
  • 2) business logic tier (which are clean from jsf stuffs / imports, doing only pure business logic stuffs)
  • 3) persistence tier

I imagine tier 1.5(jsf bean) initializing and calling tier 2(business logic objects), supplying arguments when calling business methods, fetching result, populating the result into jsf bean properties, so that the ui could render correctly.

What im curious is the fact that the tier 2(business logic objects) could do validations on the supplied arguments, or validating data, etc, and could throw exceptions or error objects.

I think i could handle the exceptions and get the error objects in the tier 1.5(jsf managed beans), but how am i supposed to display the error in the rendered pages ? I cant seem to find it from the book im reading, but i’m hoping there’s a way to create a global error message and somehow could inject it into somewhere so that it gets rendered by the tag ?

Thank you !

  • 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-18T04:38:31+00:00Added an answer on May 18, 2026 at 4:38 am

    You can use FacesContext#addMessage() to add a FacesMessage to the context programmatically.

    FacesContext facesContext = FacesContext.getCurrentInstance();
    FacesMessage facesMessage = new FacesMessage("This is a message");
    facesContext.addMessage(null, facesMessage);
    

    When you set the client ID argument with null, it will become a global message. You can display and filter them using <h:messages />

    <h:messages globalOnly="true" />
    

    The globalOnly="true" will display only messages with a null client ID.

    You can however also specify a specific client ID.

    facesContext.addMessage("formid:inputid", facesMessage);
    

    This one will then end up in

    <h:form id="formid">
        <h:inputText id="inputid" />
        <h:message for="inputid" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.