2
I’d like your help. I am developing a system in JSF, and I have the following need: I would like to pass a bean function as an argument from a function of mine in JS, so that I certain future moment I can call such a function. For example:
..Server Side..
class oi{
void diga ola(){}
}
....Xhtml Page....
function foo(f){}
foo(#{oi.ola()});
.....
Ah, you could tell me to use the "p:remoteCommand" which is a component of the primefaces, however the code would get ridiculously large. I have observed that it generates a function called "Primefaces.ab(...)", but unfortunately I did not understand how it recognizes the function that should be called and did not find a documentation that shows its functioning.
What I want to do is a dialog where the content is generic, and this functionality already works. However, I would like to have the possibility of calling a bean function when the dialog is closed so is hj:
<p:menuitem action="#{função quando abre dialog}" oncomplete="wizardComponent.openDialog('título do dialog,'conteudododialog.xhtml')" value="texto apresentado no menu "/>
In case I wanted to pass another argument to function, so:
openDialog("título do dialog,'conteudododialog.xhtml', #{função a ser chamada quando o dialog fechar})
Any suggestion is welcome.
Hello, thanks for the suggestion. Getting the closing event is not my problem. What I want to pass is the #{dialogBean.suaFuncaoDeechamento} as an argument of a javascript function of mine, because I manage the dialog by JS, and in case I want the solution to be generic.
– Thaylon Guedes Santos
Have you seen how the
PrimeFaces.ab
, which is a shortcut toPrimeFaces.ajax.AjaxRequest
? Example:PrimeFaces.ab({formId:'dialogForm',source:'dialogForm:componenteQualquerId',process:'@all',update:'growl'})
With it, you can call your methods on bean via Javascript.– Victor T.