开发者

Reference the oncomplete event by an external java script function

开发者 https://www.devze.com 2022-12-30 10:40 出处:网络
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 f

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消