How can I launch a dialog according to some conditions? I am using primefaces components.
With 3.x, RequestContext also provides an easier api called execute.
RequestContext.getCurrentInstance().execute("dialogue.show()");
RequestContext provides a useful API to pass parameters from JSF backing beans in json format to ajax callbacks like oncomplete. Execute javascript from server side and add components to update programmatically.
An example of code for Backend Bean:
RequestContext context = RequestContext.getCurrentInstance();
if (condition)
{
context.addCallbackParam("someVariable", true);
}
else
{
context.addCallbackParam("someVariable", false);
}
We wand to write a javaScript function in the frontend (xhtml ) to handle this callback,like this
function precautionsDialogShow(xhr, status, args)
{
if(args.someVariable)
{
dialogue.show();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With