ADF Block UI Input

来源:互联网 发布:金吉数据黑匣子 编辑:程序博客网 时间:2024/06/06 12:57

功能:在ADF界面上通过Lov选择或者是直接输入经销商,点击goButton按钮,则使用脚本弹出一个页面加载数据。

 

问题:在事件没有执行完成之前,用户手工更改了经销商,即键盘输入,再次点击按钮,最后生成的数据跟前一次数据一样。

 

原因:传递过去的ID没有发生改变。

 

需求:在事件没有执行完成之前,不允许用户更改条件。

 

解决方法:

利用ADF Faces JavaScript API中的AdfBaseEvent.preventUserInput function来阻止事件运行中的用户输入。

 

The ADF Faces JavaScript API includes the AdfBaseEvent.preventUserInput function. To prevent all user input while the event is processing, you can call the preventUserInput function, and a glass pane will cover the entire browser window, preventing further input until the event has completed a roundtrip to the server.

 

You can use the preventUserInput function only with custom events, events raised in a custom client script, or events raised in a custom client component's peer. Additionally, the event must propagate to the server.

 

脚本如下:

function queueEvent(event)
{
   event.cancel(); // cancel action event
   var source = event.getSource();
        
   var params = {};
   var type = "customListener";
   var immediate = true;
   var isPartial = true;
   var customEvent =  new AdfCustomEvent(source, type, params, immediate);
   customEvent.preventUserInput();
   customEvent.queue(isPartial);
}  

 

完成了脚本,需要由组件来触发。在goButton里添加client listener事件:<af:clientListener method="queueEvent" type="click"/>

 

由于goButton按钮同时要去调用另外一个脚本doDistributorConfirmLetterEvent做打开新窗口的事情,因此调用顺序queueEvent应放在

doDistributorConfirmLetterEvent之后,或者将2个脚本融合在一起。

 

             <af:goButton text="生成经销商确认函" inlineStyle="width:200px; text-align:center;" id="doEventId">
                <af:clientListener type="click" method="doDistributorConfirmLetterEvent"/>
                <af:clientListener method="queueEvent" type="click"/>
              </af:goButton>

原创粉丝点击