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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:17:32+00:00 2026-05-15T14:17:32+00:00

I am using JSF Myfaces Impl 1.2 without tomahawk and other libs : I

  • 0

I am using JSF Myfaces Impl 1.2 without tomahawk and other libs :

I am using different styles + images to show JSF Error messages, find below a sample.

<h:panelGroup rendered="${adminBean.showErrorIcon==2}">
<table width="375" align="center" class="InfoMsg" border="1"
    cellspacing="0" cellpadding="0">
    <tr>
    <td>
    <table width="375" align="center" class="InfoMsg" border="0">
        <tr>
            <td width="50"><img src="static/images/info_icon.gif"
                width="40" height="40" border="0" /></td>
            <td width="325" align="left"><h:messages layout="table"
                errorClass="InfoMsg" /></td>
        </tr>
    </table>
    </td>
</tr>
</table>

Based on the int variable of the Backing Bean , I am displaying a diff image and the corresponding FacesMessage(s) in the screen – only 2 cases – error or an information.

I am using the below code to set the variable of the Backing Bean

//Checking if there are messages!
    log.debug("Checking if there are messages to be shown ]");
    if(getShowErrorIcon()==99){//Set only if the value is still the default :
        log.debug("getShowErrorIcon was DEFAULT - Changing it ]");
        Iterator<FacesMessage> messages = FacesContext.getCurrentInstance().getMessages();
        if(messages != null && getShowErrorIcon()==99){//Set Error/Info for messages that are not added here :
            while(messages.hasNext()){
                log.debug("There are ***messages***");
                FacesMessage aMessage =(FacesMessage) messages.next();
                if(aMessage.getSeverity().compareTo(FacesMessage.SEVERITY_ERROR)==0){
                    setShowErrorIcon(1);
                    break;//just once is enough
                }
                if(aMessage.getSeverity().compareTo(FacesMessage.SEVERITY_INFO)==0){
                    setShowErrorIcon(2);
                    break;
                }
            }
        }
    }//if it is not default, then something has been set already, why again?

Now the problem I have is , There are FacesMessage(s) that are added by the MyFacesImpl – like the required=true and the custom validator messages which are added during PROCESS_VALIDATION Phase, These are not shown in the screen since my integer variable of the Backing Bean is not set , and since the INVOKE_APPLICATION Phase was not called (and that means the above code was not called!!!)

How do I resolve this? Or Whats the best way / Where’s the best place to place the above checking code ?

Appreciate your help.Thanks!

  • 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-15T14:17:33+00:00Added an answer on May 15, 2026 at 2:17 pm

    I’m not sure, but this all look like unnecessarily overcomplicated. To change icons/styles based on the message severity, just make use of the CSS powers. You can specify different CSS classes based on message severity using infoClass and errorClass attributes of the <h:messages> and you can specify the icons as CSS background image.

    JSF:

    <h:messages id="messages" layout="table" infoClass="info" errorClass="error" />
    

    CSS:

    #messages .info td {
        background: url('info.gif') no-repeat left center;
        padding-left: 15px;
    }
    #messages .error td {
        background: url('error.gif') no-repeat left center;
        padding-left: 15px;
    }
    

    The <h:messages layout="table"> itself already renders a HTML <table>. I think the whole table around it is unnecessary as well. Just apply styles accordingly the usual CSS way.

    #messages {
        width: 375px;
        margin: 0 auto;
        border: 1px black solid;
        border-collapse: collapse;
    }
    

    See also:

    • W3schools CSS tutorial/reference
    • CSStutorial.net CSS tutorial

    Update: as per the comments, you’re looking for something like this:

    <h:messages layout="table" styleClass="messages info" infoClass="info" errorClass="error" />
    <h:messages layout="table" styleClass="messages error" infoClass="info" errorClass="error" />
    

    with CSS:

    .messages {
        width: 375px;
        margin: 0 auto;
        border-collapse: collapse;
        border: 1px black solid;
    }
    .messages.info {
        background: url('info.gif') no-repeat left center;
    }
    .messages.error {
        background: url('error.gif') no-repeat left center;
    }
    .messages.info tr.error, .messages.error tr.info {
        display: none;
    }
    .messages td {
        padding-left: 15px;
    }
    

    This shows two separate message tables, one for info and other for error messages, each with a single icon on the left center.

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

Sidebar

Ask A Question

Stats

  • Questions 443k
  • Answers 443k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try "escaping" the "escape" operator, so that it survives Sweaving… May 15, 2026 at 6:17 pm
  • Editorial Team
    Editorial Team added an answer Put it in a hidden input element. In this case,… May 15, 2026 at 6:17 pm
  • Editorial Team
    Editorial Team added an answer You could also consider spitting out an additional http header… May 15, 2026 at 6:17 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.