I want to do some logic at the oncomplete attribute of the a4j:commandButton ,but my logic is too complicated , can I reference the code using a java script functions located in a external java-script file to have a better maintenance ? I found it has error because the JavaScript file cannot understand the EL expression .
For example , originally I have ,
<a4j:commandButton id="btn1" action="#{MBena1.action1}" oncomplete="if( {MBena1.variable1}){Richfaces.showModalPanel('modelPanel1');};if (......) then ">
I want to do something like this:
<a4j:commandButton action="#{MBena1.action1}" oncomplete="Btn1OnComplete();">
the code is put inside the java script function Btn1OnComplete() which is located 开发者_Python百科in a external java-script file.
Thanks
Just pass the bean value as an argument:
oncomplete="Btn1OncOmplete(#{mBean1.value});"
and then, in the external javascript function you don't need to write any jsf-related code.
精彩评论