JSF中的ActionListener阶段 [英] ActionListener phases in JSF

查看:176
本文介绍了JSF中的ActionListener阶段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI

我对在JSF bean中调用ActionListener方法有疑问.例如,每一个JSF表单的请求或提交都经历了六个阶段的生命周期.但是,当我们触发诸如动作侦听器或值更改侦听器之类的特定事件时,该请求是否有任何生命周期?

I have a doubt on calling the ActionListener method in the JSF beans. For example every request or submission of JSF form is gone through the life cycle of six phases. But, when we are triggering the particular event like action listener or value change listener, is there any lifecycle associated with that request?

请澄清我.

推荐答案

在实际动作方法之前,在调用动作"阶段 期间,将调用任何动作侦听器.根据与提交相关联的UICommand组件的actionListener属性,确定要调用哪些动作侦听器方法.

Any action listener is invoked during invoke action phase, before the real action method. Which action listener methods are to be invoked are determined based on the actionListener attribute of the UICommand component which is associated with the submit.

在验证阶段(或对于特定UIInput组件的immediate="true"时,应用请求值阶段)在 成功地转换/验证提交的值和仅(当提交的值与初始值不同时).根据与提交相关联的UIInput组件的valueChangeListener属性,确定要调用哪些值更改侦听器方法.

Any value change listener is invoked during validations phase (or apply request values phase when immediate="true" for the particular UIInput component) after a succesful conversion/validation of the submitted value and only when the submitted value differs from the initial value. Which value change listener methods are to be invoked are determined based on the valueChangeListener attribute of the UIInput components which are associated with the submit.

不,他们没有自己的生命周期.当他们完成执行并返回时,它仍然处于生命周期的同一阶段.调用valueChangeListener后,JSF将继续进行下一个UIInput组件的转换/验证,或者如果没有,则进入下一个阶段.调用actionListener后,JSF将继续执行下一个actionListener;如果没有,则调用实际操作方法.

And no, they do not have their own lifecycle. When they finish executing and return, it's still inside the same phase of the lifecycle. After invoking the valueChangeListener, JSF will continue with conversion/validation of the next UIInput component, or if there are none, then proceed to the next phase. After invoking the actionListener, JSF will continue with the next actionListener or if there are none, invoke the real action method.

更新:在再次阅读您的评论之后,我认为我现在看到您对特别是价值变化侦听器的怀疑.您似乎认为默认情况下,它会在客户端更改事件期间立即向服务器端触发一个全新的请求.默认情况下,它会执行 not .您只能通过添加一小段 JavaScript代码来实现此目的,该代码会在HTML输入字段的change事件期间提交整个HTML表单.

Update: after reading your comments again, I think that I now see your doubt about particularly the value change listener. You seem to think that it by default immediately fires a brand new request to the server side during the client side change event. It does that not by default. You can only achieve this by adding a little piece of JavaScript code which submits the entire HTML form during the change event of the HTML input field.

onchange="this.form.submit()"

这部分与JSF无关.这是一个简单的HTML属性.在网络浏览器中打开页面,右键单击并选择查看源代码.您会看到它在那里.在浏览器中禁用JavaScript或以JSF代码将其删除,您将发现它不再起作用.您需要按下提交按钮您自己才能使其全部运行.

This part has nothing to do with JSF. It's a simple HTML attribute. Open the page in webbrowser, rightclick and choose View Source. You'll see that it's there. Disable JavaScript in your browser or remove it in JSF code and you'll see that it won't work anymore. You would need to press the submit button yourself to get it all to run.

这篇关于JSF中的ActionListener阶段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆