The main purpose of conversion and validation is to ensure values have been properly sanitized before updating model data. Subsequently, when the time comes to invoke application methods to actually do something with that data, you can safely make certain assumptions about the state of your model. Conversion and validation allow you to focus on business logic rather than the tedious qualifications of input data such as null checks, length qualifiers, range boundaries, etc.
It makes sense, then, that conversion and validation processes happen before component data is bound to your backing bean model in the update model data lifecycle phase. As you saw in Figure 1, conversion occurs in the apply request values phase and validation in the process validations phase. These phases are highlighted in Figure 2.
Figure 2. Conversion and validation phases of interest
About the immediate attribute
Note that the conversion and validation processes outlined in Figure 2 represent the application flow when the UIInput
component's immediate
attribute is set to false
. Were the attribute set to true
, conversion and validation would occur earlier in the lifecycle, during the apply request values phase (see Figure 3). A detailed discussion about using the immediate attribute is beyond the scope of this article, but there are instances where it is useful -- such as managing dynamic lists (which you may recall from the previous article in this series) and even bypassing validation altogether (when used with a UICommand
component). Can you think of an application where it would be useful to bypass validation completely?
Figure 3 shows where conversion and validation would occur in the JSF application lifecycle were the immediate
attribute set to true
.
Figure 3. When the immediate attribute is true
Basically, in any scenario where a user must enter data, that data must be validated. If the overall data entry is optional, however, then validation need not occur. One way of working around the validation phase of the JSF lifecycle is to utilize the UICommand
component's immediate
attribute, which can force the action to be invoked during the apply request values phase before the process validations phase (rather than during the invoke application phase, which occurs after the process validations phase).
The immediate
attribute allows you to control page flow through standard navigation rules while bypassing validation altogether. You could implement this technique for specific scenarios such as online wizards with optional steps and/or forms (such as when the user clicks the Skip button to advance to the next view) or in cases where the user cancels out a form for some reason.
分享到:
相关推荐
总结来说,动态SQL语句在高校教学系统开发中扮演着重要角色。它不仅提高了系统的灵活性,而且优化了数据处理流程,为高校教学管理系统的稳定运行提供了技术保障。在实际应用中,开发人员需要根据具体的业务需求灵活...
- immediate属性用于指定是否在watch创建时立即执行一次handler函数。这对于需要在组件创建时就初始化某些操作的场景非常有用。例如,watch: { data: { handler: function(newVal) { console.log(newVal); }, ...
总结来说,`watch` 和 `computed` 都是 Vue 中响应式数据处理的重要工具,但它们的应用场景不同。`watch` 更注重于监听数据变化后的动作执行,而 `computed` 关注的是根据数据生成新的计算结果。在实际开发中,理解...
总结来说,3D游戏开发的高级应用涉及到一系列复杂的3D图形技术,包括但不限于动画控制、场景构建、纹理映射、光照效果、动画序列和对象变换。JSR 184提供的3D API为开发者提供了工具,让他们能在有限的移动平台上...
总结来说,Ajax4JSF通过`a4j:ajaxListener`、`a4j:region`和`a4j:page`等标签提供了强大的功能,使开发者能够轻松实现JSF应用中的AJAX交互,提高用户体验。通过理解并熟练使用这些标签,你可以创建更动态、响应更快...
总结,JSF标签是构建JSF应用的关键组成部分,它们提供了丰富的UI组件和灵活的属性配置,使得开发者能够高效地创建动态、数据驱动的Web界面。理解并熟练运用这些标签,可以极大地提高开发效率和应用的质量。
总结,Vue.js 的`watch`功能强大且灵活,它让我们能够精确地响应数据变化,执行相应的处理。理解和掌握`watch`的用法对于提升Vue应用的开发效率和用户体验至关重要。在实际项目中,应根据需求选择合适的监听策略,...
Watch还支持immediate(立即执行)和deep(深度监听)属性。 - **Vue 响应式原理**:Vue 2.x使用`Object.defineProperty()`实现数据绑定,Vue 3.x则采用Proxy来监听对象属性的变化,提供更强大的数据代理。 2. **...
- **表(Table)**:是最基本的数据存储单元,它由行和列组成,每行代表一个记录,每列代表一种属性。 - **视图(View)**:是从一个或多个表派生出来的虚拟表,不实际存储数据,只存储定义视图的SQL查询语句。 - **...
【历年真题中出现的单词与词组总结】 在备考英语四六级的过程中,了解历年真题中出现的单词与词组是至关重要的。这些词汇和短语是考试中的常见元素,掌握它们能够帮助考生提高阅读理解、听力理解以及写作和翻译的...
- 如果组件的`immediate`属性未设置为`true`,则执行转换操作。 - 转换失败会导致错误消息,这些消息会被存储在`FacesContext`中,稍后在渲染阶段显示。 - 若`immediate`属性设置为`true`,则进行即时转换和验证...
总结来说,"由标题来获取窗口类别"的VBA实例展示了如何利用Excel的VBA功能动态响应窗口标题变化,并根据窗口类别执行相应的操作。通过学习和实践此类实例,Excel用户可以提升他们的办公自动化能力,实现更高效的工作...
4. **调试工具**:VBA编辑器提供了一些调试工具,如断点、步进执行(Step Into)、监视窗口(Watch Window)和立即窗口(Immediate Window),它们对于查找和修复错误极其重要。 5. **事件处理程序**:VBA中的事件...
- **应用程序关键部分回顾**:总结了应用程序的关键组成部分及其作用。 #### 3. JavaServer Faces 请求处理生命周期 - **JSF 请求处理生命周期高度概述**:介绍了请求处理生命周期的基本流程,包括各个阶段的作用...
与`immediate="true"`不同,后者跳过所有验证,但`ajaxSingle`仅限于Ajax请求。 5. **减少RichFaces组件使用**: - 虽然RichFaces提供了丰富的功能,但过度依赖可能会导致性能问题。适当减少组件使用,寻找替代...
- Vue3引入了一些新的内置组件,如Teleport、Suspense,增强了应用的灵活性和用户体验。 了解和熟练掌握以上知识点对于Vue开发者来说至关重要,它们涵盖了Vue的核心概念和常见实践,不仅有助于面试,也能提升实际...
总结起来,Vue的`watch`功能提供了灵活的方式来响应数据变化,通过`immediate`和`deep`属性,我们可以更好地控制何时以及如何处理数据的改变。这使得Vue应用能够更加智能地响应用户操作,提升用户体验。在实际开发中...
10.8 集合和列表总结 303 10.9 小结 306 第11章 ASP.NET 2.0中的数据绑定 307 11.1 数据源控件 307 11.1.1 SqlDataSource控件 310 11.1.2 XmlDataSource控件 316 11.1.3 ObjectDataSource控件 316 11.1.4 ...
21.1.2 Immediate和 Command窗口711 21.1.3 任务列表712 21.2 跟踪713 21.2.1 System.Diagnostics. Trace和ASP.NET 的Page.Trace713 21.2.2 页面级的跟踪713 21.2.3 应用程序的跟踪714 21.2.4 查看跟踪...