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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:19:15+00:00 2026-06-11T10:19:15+00:00

I want to present validation messages and messages from backing bean in <p:dialog> component.

  • 0

I want to present validation messages and messages from backing bean in <p:dialog> component. In my JSF page I have following dialog defined:

<p:dialog widgetVar="messageDialog" id="msgDialog" modal="true" appendToBody="true">
    <h:form id="messageForm">
        <p:messages id="messagesInDialog" />
        <p:commandButton value="OK" onclick="messageDialog.hide()" />
    </h:form>
</p:dialog>

I execute the following code after appending some message in backing bean:

RequestContext.getCurrentInstance().execute("messageDialog.show()");

and it works fine.

However, I also want to display bean validation messages in this dialog. Messages are appended to <p:message> component afer validation, but I have no idea how to display this dialog after validation failure.

How can I achieve this?

  • 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-11T10:19:16+00:00Added an answer on June 11, 2026 at 10:19 am

    You can use the visible attribute of <p:dialog> to specify whether the dialog should show up by default or not. You can check by FacesContext#isValidationFailed() if there’s a validation failure or not.

    So, in a nutshell:

    <p:dialog id="msgDialog" widgetVar="messageDialog" modal="true" appendToBody="true"
        visible="#{facesContext.validationFailed}">
        <p:messages id="messagesInDialog" />
        <p:button value="OK" onclick="messageDialog.hide()" />
    </p:dialog>
    

    (note that I simplified the unnecessary h:form and p:commandButton by a p:button)

    Which is then to be updated by:

    <p:commandButton value="submit" update=":msgDialog" />
    

    Or by just placing it inside a <p:outputPanel autoUpdate="true"> so that it auto-updates itself on every ajax request without the need to specify it in every update attribute:

    <p:outputPanel autoUpdate="true">
        <p:dialog id="msgDialog" widgetVar="messageDialog" modal="true" appendToBody="true"
            visible="#{facesContext.validationFailed}">
            <p:messages id="messagesInDialog" />
            <p:button value="OK" onclick="messageDialog.hide()" />
        </p:dialog>
    </p:outputPanel>
    

    See also:

    • Difference between rendered and visible attributes of <p:dialog>

    Unrelated to the concrete problem, to cover non-validation messages, such as those global messages which you add in the action method, rather check instead if FacesContext#getMessageList() is not empty.

    <p:dialog ... visible="#{not empty facesContext.messageList}">
    

    This will then show the dialog when there is any message. This way that RequestContext#execute() call is unnecessary.

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

Sidebar

Related Questions

I have a UINavigationController/UITableView and I want to present a UIView over top of
I have two screens on my app that I want to present to users,
I have a TimePickerDialog with is24Hour set to false since I want to present
I have a dilema, I want to present to the user a semi-transparent view.
Richfaces 3.3.3, Jsf 1.2: I have a a4j:form that uses some simple validation, mainly
I want to merge to xsd's, so validation can be done if there present
I have an NSOpenPanel and I want to do some validation of the selection
I have a page and want to use TinyMCE to edit certain elements on
I want to apply scope limiter in my custom validation I have this Product
I want to present an iPad game which is only playable in portrait mode

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.