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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:08:48+00:00 2026-06-03T22:08:48+00:00

My xhtml page code: <h:outputLabel value=Email address: /> <h:inputText id=email value=#{userBean.emailAddressBeingEdited} required=true requiredMessage=* />

  • 0

My xhtml page code:

<h:outputLabel value="Email address: " />
<h:inputText id="email" value="#{userBean.emailAddressBeingEdited}" required="true" requiredMessage="*" />
<h:message for="email" id="emailM"/>

My java code:

FacesContext.getCurrentInstance().addMessage("email", new FacesMessage("Email already in use"));

I tried nesting the h:message in the h:inputText, but that did not work. If I need to provide more information, please ask.

  • 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-03T22:08:50+00:00Added an answer on June 3, 2026 at 10:08 pm

    The client ID which you specify in addMessage() has to be the real client ID, not the component ID. The client ID of an input component is usually prefixed with the ID of the parent form component. For starters who haven’t memorized which JSF components implement NamingContainer and how client IDs are generated, the easiest way to find out the real client ID is to open the page in browser, view its source and locate the generated HTML <input type="text"> element and finally take its id. If you have given the <h:form> an ID of formId, it’ll be formId:email. That’s the real client ID which you need to specify in addMessage().

    context.addMessage("formId:email", message);
    

    If you don’t specify the right client ID, then the message remains unhandled. If the JSF project stage is set to Development, then JSF will automatically append it in a list of “unhandled messages” in the end of the body. This is what you’re seeing. View the generated HTML source to see it yourself, it’s the autogenerated HTML list <ul id="javax_faces_developmentstage_messages">.


    Unrelated to the concrete problem, you seem to be doing the validation in the JSF bean action method. This is not the right way. You should be using a Validator for this. This way you don’t need to worry about the client IDs. You just need to throw a ValidatorException with a FacesMessage. E.g.

    @FacesValidator("uniqueEmailValidator")
    public class UniqueEmailValidator implements Validator {
    
        @Override
        public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
            // ...
    
            if (emailIsAlreadyInUse) {
                throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Email is already in use", null));
            }
        }
    
    }
    

    which you then register as <f:validator validatorId="uniqueEmailValidator" /> inside the input component.

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

Sidebar

Related Questions

<%@ Page Language=C# AutoEventWireup=true CodeFile=Default.aspx.cs Inherits=_Default %> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
I have a JSF 2 .xhtml page with javascript in the page code. In
A button on page xyz.xhtml does invoke this code (using ajax). FacesContext fc =
I've written an .xhtml page with the following code: <html> <head> <title>Test</title> </head> <body>
I have the following code (on a xhtml page) <div style=background-color:#006400;> <div id=div1 style=display:inline-block;
So I have an xhtml page that contains the following code: <rich:fileUpload id=uploadReportTemplate addControlLabel=Add
i've got this jsf code <f:view> <rich:page pageTitle=My Page markupType=xhtml> ... <rich:panel id=content> <a4j:include
I've got an xhtml page validating under xhtml strict doctype -- but, I getting
In my xhtml page I have the following tag included: <f:view locale=#{languageBean.locale}> ... </f:view>
I have a well formed XHTML page. I want to find the destination URL

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.