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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:17:43+00:00 2026-05-28T17:17:43+00:00

On clicking the Submit button I have to do application/business level validations and associate

  • 0

On clicking the Submit button I have to do application/business level validations and associate the error message to a link. As I cannot do that is there any way that I can place the error message on top of the link.

My validation for business logic is in the action method

FacesMessage message = new FacesMessage();
message.setSeverity(FacesMessage.SEVERITY_ERROR);
message.setSummary("ERROR MESSAGE");
message.setDetail("ERROR MESSAGE");
FacesContext.getCurrentInstance().addMessage("linkId", message);

Help is greatly appreciated

  • 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-28T17:17:44+00:00Added an answer on May 28, 2026 at 5:17 pm

    The first argument of FacesContext#addMessage() must be the client ID, not the component ID. The client ID is whatever you see as ID of the HTML element in the generated HTML output (as you can see by rightclick page and View Source in browser). For JSF input and command components in a form this is usually prefixed with the ID of the form.

    So, for the following link,

    <h:form id="formId">
        ...
        <h:commandLink id="linkId" ... />
        <h:message for="linkId" />
    </h:form>
    

    you should be adding the message as follows:

    FacesContext.getCurrentInstance().addMessage("formId:linkId", message);
    

    However, the more canonical approach for displaying global messages as you would do from within an action method is just using <h:messages globalOnly="true" /> which you can fill with messages with a null client ID.

    So,

    <h:form id="formId">
        ...
        <h:commandLink id="linkId" ... />
        <h:messages globalOnly="true" />
    </h:form>
    

    with

    FacesContext.getCurrentInstance().addMessage(null, message);
    

    See also:

    • How to use JSF h:messages better?
    • Creating FacesMessage in action method outside JSF conversion/validation mechanism?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP page, that on clicking the submit button process a few
I have 2 text boxes and a submit button.On clicking on the submit button
Well , I have a page with a submit button. When Clicking on the
I am clicking a submit button using this: $('input[type=submit]').click(); The problem is that I
I have a form with a submit button. On clicking the submit button, i
This is a little form that I have that is a submit button a
I have an application that can be used without authentication on computers in public
I have a login form with an event of clicking the enter to submit
How can I prevent onbeforeunload from being called when clicking the submit button? $(document).ready(function()
How does one link to the submit button, I am thinking of embedding a

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.