`
kirenenko04
  • 浏览: 152033 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

Data Binding and Explicit Transactions

 
阅读更多

 Data Binding and Explicit Transactions

数据绑定和显式事物

 

Data Binding with Forms and Objects 数据绑定到表单和对象

The Demandware forms framework supports binding of persistent(持久) objects to form fields by automatically updating a persistent object with form data without having to issue an insert statement or calling a Demandware API. The reverse mechanism is also supported: pre-populating a form object with data from a persistent object.

 

The object that is bound to the form must be a persistent object (system or custom), and must be available in the pdict. The form metadata must have field(s) with the binding attribute specified. The field formid attribute is not used to make the match; only the binding attribute identifies what fields match between the form and the object.

 

This is because the NewsletterSubscription CO we want to bind this form to have firstName, lastName and email fields which are all custom attributes, as seen below since the fields don’t have a lock icon (they were added by you as custom attributes of the CO):

 

Using the UpdateObjectWithForm Pipelet

The UpdateObjectWithForm pipelet updates an existing persistent object with data from the form. It requires the object to update and the form object both available on the pdict. It is transactional by default since the object to be updated must be a persistent object.

 

Here is an example of how you define the properties of the pipelet using the newsletter form and NewsletterSubscription object we saw above:

 

Form: CurrentForms.newsletter

Object: Subscription

 

The pipelet will inspect(检查) the CurrentForms.newsletter form in the pdict, and try to match every field with a binding attribute to a column in the object called Subscription. This object must be an instance of NewsletterSubscription that was placed in the pdict by either creating a new instance (using CreateCustomObject pipelet) or by retrieving an existing instance (using SearchCustomObject pipelet).

If the Subscription object is null, or not an instance of NewsletterSubscription CO, or the form is not in the pdict, the pipelet will fail and the transaction will be rolled back. If the pipelet is successful the transaction will commit.

 

Using UpdateFormWithObject Pipelet

The UpdateFormWithObject pipelet updates a form with data from an object. It requires the form to update and the object to be both available on the pdict. It is not transactional since the updated form lives in the pdict scope, not in the database.

 

Notice that a form group may be updated with an object: as long as the bindings match, just that part of the form will be updated.

 

Form: CurrentForms.profile.customer

Object: CurrentCustomer.profile

 

In the example above, the profile.xml form has a customer group that will be updated with the existing profile data from the logged in customer.

 

Explicit Transaction Handling 显式事务处理

We already saw that transaction handling can be done implicitly by just executing a transactional pipelet: the commit or rollback is controlled by the PIPELET_NEXT or PIPELET_ERROR return values.

 

However, in some circumstances(情况) the transaction spans(跨越) several pipelets or steps: in this case you need to decide where the transaction begins and ends. This mechanism is called Explicit Transaction Handling.

 

Explicit Database Transaction Handling

This is implemented(应用于) at the pipeline level by changing the Transaction Control property of a transition or connector.

You Can use ‘Begin Transaction’, ‘Commit Transaction’, ‘Rollback Transaction’ for setting on the transition node, simply open the properties window for the transition, and select the type of Transaction Control you want.

 

This can be used to override(覆盖) the built-in(内置) implicit transaction in order to group changes that need to be an atomic transaction (原子事件).

 

分享到:
评论

相关推荐

    Android Data Binding

    Android Data Binding库是Google推出的一种强大的MVVM(Model-View-ViewModel)架构支持技术,它旨在简化Android应用中的UI逻辑,提高代码可读性和可维护性。本教程将深入探讨如何将Data Binding与RecyclerView结合...

    Data Binding with Windows Forms 2.0

    Data Binding with Windows Forms 2.0: Programming Smart Client Data Applications with .NET By Brian Noyes ............................................... Publisher: Addison Wesley ...

    WPF Data Binding with LINQ to SQL

    These tutorials describe how to map your classes to your tables manually (rather than with an automated tool like SqlMetal) so that you can have support for M:M relationships and data binding against ...

    Data Binding with Windows Forms 2.0 Programming

    This book is all about the what and the why of binding to data sources in a Windows Forms application built using Visual Studio 2005. The book goes into great detail in explaining the rationale behind...

    Android Data Binding 代码实战 demo

    **Android Data Binding 框架详解与实战演示** 在Android应用开发中,数据绑定是一种将UI组件和数据源紧密关联的技术,它可以帮助开发者减少在Activity或Fragment中的样板代码,提高代码可读性和维护性。本实战项目...

    Android Data Binding实战-入门篇

    Android Data Binding是Google推出的一种强大的数据绑定库,它旨在简化Android应用中的UI逻辑,通过将数据绑定到XML布局文件中,使代码更加清晰、可读性更强,同时也减少了Activity或Fragment中的样板代码。...

    Approaches and Best Practices in Web Service Style, Data Binding and Validation.pdf

    本文档探讨了网络服务(Web services)的各种风格及其在数据绑定(data binding)和验证(validation)方面的不同方法,旨在为大型系统开发提供指导。网络服务作为现代分布式计算的核心组成部分,其设计与实现对系统...

    Android Data Binding 在 library module 中遇到错误及解决办法

    在使用Android Data Binding时,有时会遇到在library module中出现错误的情况。这通常是由于Data Binding在编译过程中生成的binding类与library module的特定规则不兼容导致的。本文将深入探讨这个问题并提供解决...

    AdventureWorks Data Binding sample

    本文将深入探讨“AdventureWorks Data Binding sample”,这是微软提供的一款用于演示VB.NET数据绑定特性的实例。 首先,让我们了解数据绑定的基本概念。数据绑定允许UI控件(如文本框、列表视图等)直接与数据源...

    Android Data Binding Adapter for ListView and RecyclerView..zip

    Android Data Binding Adapter for ListView and RecyclerView..zip,使用新的android数据绑定框架将集合绑定到listviews和recyclerviews的简单方法

    Flex Data Binding详解

    Flex Data Binding是Adobe Flex框架中的核心特性之一,它允许开发者创建数据驱动的应用程序,通过将UI组件的属性与数据模型的属性直接关联,实现实时的数据同步。在Flex中,数据绑定确保当数据源发生变化时,相关的...

    AndroidDataBindingExample, Android Data Binding 代码实战.zip

    Android Data Binding 是 Android 平台上的一种强大的数据绑定框架,它简化了UI与数据之间的交互,使得开发者能够更专注于业务逻辑,而不是繁琐的事件处理和视图更新。这个压缩包"AndroidDataBindingExample, ...

    ADF的data binding

    2. **Iterator Bindings and Control Bindings**:Iterator Bindings负责管理集合数据,它们与提供集合数据的Data Control协作,用于在UI上展示数据。Control Bindings则定义了如何将用户界面控件与业务方法或单个...

    Android数据绑定Data Binding

    在Android开发中,数据绑定(Data Binding)是一个强大的框架,它允许开发者更加直观地将UI组件与业务数据关联起来,从而简化代码并提高可维护性。这个Demo程序旨在展示数据绑定和事件绑定的基本用法,帮助开发者...

    安卓-Data Binding+RecyclerView打造可以选择的三级列表

    在安卓应用开发中,构建可交互的用户界面是至关重要的,而Data Binding库与RecyclerView的结合使用能够有效地提高代码的可读性和维护性,同时实现复杂的列表展示,如本示例中的三级列表。本文将详细解析如何利用Data...

    Android代码-数据绑定验证工具,快速帮你验证表单数据绑定状况

    The Data Binding Validator makes it easy and quick to validate fields in forms using data binding framework. Download Step 1: Add it in your root build.gradle at the end of repositories: allprojects {...

    Android Data Binding Library 官方文档(译)

    Android Data Binding Library 官方文档中文翻译,出自https://blog.csdn.net/jjwwmlp456/article/details/54915981的博客,被我制作成离线版pdf以供保存, Google官方文档地址:...

    Data Binding with Windows Forms 2.0 Programming Smart Client Data Applications with .NET

    《Data Binding with Windows Forms 2.0:编程智能客户端数据应用程序与.NET》是一本深入探讨.NET框架下Windows Forms 2.0数据绑定技术的专业书籍。数据绑定是将用户界面(UI)组件与数据源连接的过程,它使得应用...

Global site tag (gtag.js) - Google Analytics