Running JSF dialog conditionally

How to start a dialog in accordance with some conditions? I use surface components.

+4
source share
2 answers

RequestContext provides a useful API for passing parameters from JSF beans support in json format for ajax callbacks such as oncomplete . Running javascript on the server side and adding components to update programmatically.

Sample code for Backend Bean:

 RequestContext context = RequestContext.getCurrentInstance(); if (condition) { context.addCallbackParam("someVariable", true); } else { context.addCallbackParam("someVariable", false); } 

We are trying to write a javaScript function in the interface (xhtml) to handle this callback, for example,

 function precautionsDialogShow(xhr, status, args) { if(args.someVariable) { dialogue.show(); } } 
+6
source

With 3.x, RequestContext also provides a simpler api called execute.

 RequestContext.getCurrentInstance().execute("dialogue.show()"); 
+10
source

Source: https://habr.com/ru/post/1385072/


All Articles