太原做网站兼职,渝水区城乡建设局网站,工商局注册公司网站,网络设计原则是什么adf可以自定义溶剂吗在本文中#xff0c;我将重点介绍ADF Faces Javascript API方法以从客户端触发自定义事件。 例如#xff1a; function cliListener(actionEvent) {AdfCustomEvent.queue(actionEvent.getSource(), servListener,null, true);}我们可以使用a… adf可以自定义溶剂吗 在本文中我将重点介绍ADF Faces Javascript API方法以从客户端触发自定义事件。 例如 function cliListener(actionEvent) {AdfCustomEvent.queue(actionEvent.getSource(), servListener,null, true);} 我们可以使用afclientListener标记以便将cliListener函数附加到命令按钮并在单击按钮时使该函数被调用。 在服务器端我们可以捕获事件并调用托管bean方法 af:commandButton textTestButton idcb1 actiongoEdit af:clientListener typeaction methodcliListener /af:serverListener typeservListenermethod#{TheBean.serverListener}//af:commandButton 问题是–该事件将传递到哪个生命周期阶段托管bean方法将在哪个阶段触发 有时它非常重要因为它可以显着改变应用程序的行为。 让我们看一下AdfCustomEvent.queue方法的规范 /*** param {AdfUIComponent} Component to queue the custom event on* param {String} the type of the event* param {Object} a set of parameters to include on the event. Reserved* parameter names include type and immediate.* param (boolean) whether the custom event is immediate - which will* cause it to be delivered during Apply Request Values on the server,* or not immediate, in which case it will be delivered during* Invoke Application. */
AdfCustomEvent.queue function(component, type, params, immediate) { ... } 我将专注于立即数参数。 当其值为true时 客户端事件将在“ 应用请求值”阶段传递。 因此它将在“ 调用应用程序”阶段触发命令按钮的动作和动作侦听器方法之前触发。 而且如果即时参数的值为false 则客户端事件将在命令按钮的操作和操作侦听器方法之后在“ 调用应用程序”阶段触发。 让我们考虑一个非常简单的任务流的示例 有两个视图活动 BrowseView和EditView 。 它们每个都有一个PageDef文件。 BrowseView包含上面描述的TestButton 。 此按钮会触发goEdit操作因此当用户单击它时他们将转到EditView活动。 除此之外单击按钮还调用cliListener JS函数该函数将servListener自定义事件发送到服务器。 该事件将被捕获并且将调用托管bean方法 public void serverListener(ClientEvent clientEvent) {BindingContext bc BindingContext.getCurrent();DCBindingContainer dcb (DCBindingContainer) bc.getCurrentBindingsEntry();//Do something with dcbSystem.out.println(dcbdcb.getName());
} 如果我们在JS代码中将即时参数的值设置为true function cliListener(actionEvent) {AdfCustomEvent.queue(actionEvent.getSource(), servListener,null, true);} 然后是serverListener方法 将在转到EditView之前在Apply Request Values阶段调用。 当前绑定容器的名称将如下所示 ..._pageDefs_BrowseViewPageDef_... 但是如果即时参数为false则使用serverListener方法 将在命令按钮的操作之后被调用并且当前绑定容器的名称将如下所示 ..._pageDefs_EditViewPageDef_... 本文的示例应用程序需要JDeveloper R2。 注意 以上内容对R2有好处。 在R1中行为略有不同。 如果命令组件的动作导致导航到另一个视图活动如本例所示并且客户端事件以即时假排队则将永远不会调用服务器侦听器中定义的托管bean方法。 但是如果您保持相同的视图活动则将在“ 调用应用程序”阶段执行托管bean方法。 如果即时 true则无论如何都将在服务器侦听器中定义的托管bean方法执行。 应用请求值阶段。 而已 参考 ADF Faces。 我们的JCG合作伙伴 Eugene Fedorenko在ADF实践博客上提供了即时的定制客户活动 。 翻译自: https://www.javacodegeeks.com/2014/02/adf-faces-immediate-custom-client-events.htmladf可以自定义溶剂吗