I am a Richfaces user, and their modalPanel (the equivalent of <p:dialog>
offers a showWhenRendered
attribute that could be helpful in your case.
Unfortunately, the <p:dialog>
does not seems to have such feature. What you can do, is to play with some JavaScript functions.
First, keep a flag (a boolean property, initialized to false
) in a bean that indicate if there were validation errors or not. Let's call this flag myBean.validationError
.
Now, in your page, you can add a JavaScript code that will check for this property and eventually display the dialog box. Something like that (put it at the end of the page, or at least after the dialog declaration):
<script type="text/javascript">
if (#{myBean.validationError}) {
// showDialog();
myDialog.show();
}
</script>
So in your use case, the page will be redisplay, and because there was validation errors, the flag is set to true
. Then, the if
statement is evaluated and will display the dialog to the user.