Create CreateInsert CreateWithParams的区别

先用代码来描述一下使用不同的Operation在创建一行记录时的情景

1.Create

[java]   view plain copy
  1. // create a new row for the view object  
  2. Row newRow = yourViewObject.createRow();  
  3. // mark the row as being "initialized", but not yet new  
  4. newRow.setNewRowState(Row.STATUS_INITIALIZED);  

提交时才执行insert操作

2.CreateInsert

在Create的基础上,再多执行了如下代码

[java]   view plain copy
  1. // insert the new row into the view object's default rowset  
  2. yourViewObject.insertRow(newRow);  


3.CreateWithParams

扫描二维码关注公众号,回复: 764919 查看本文章

在CreateInsert的基础上再执行以下代码,给新创建的行设置默认值

[java]   view plain copy
  1. newRow.setAttribute("attributeName", attibuteValue);  

同时,Row的状态由Row.STATUS_INITIALIZED变为Row.STATUS_NEW

由此我们想到,在创建新行时界面上表现的两种常用方式:form和table,form是直接绑定了新创建的Row,而table则是绑定了一个集合,所以在table中创建行时,只能使用CreateInsert,而在form中既可以使用Create,也可以使用CreateInsert。

转自http://blog.csdn.net/ygj26/article/details/8010123

猜你喜欢

转载自563432906.iteye.com/blog/2243698