Three ways in ADF to create a new row: Create, CreateInsert and CreateWithParams
As per fusion guide:
What happens when you use Create?
When CreateInsert is used?
It performs this additional line of code to inert the row into the row set and make it available on the iterator.
CreateWithParams does similar tasks as CreateInsert except that it gives the feasibility to define default values declaratively for the row attributes.
Suggested usages:
- With ADF forms you can use Create or CreateInsert.
- It is always safe to use CreateInsert when you have af:table as it will create a empty record and also puts it in recordset.
Transaction details:
When you create a row the transaction object associated with the current application module immediately takes note of the fact and the new entity row which gets created behind the view row is already part of the transaction's list of pending changes. As the status of new row will be marked as STATUS_INITIALIZED, it is removed from transaction's pending changes list and is considered a blank row in which the end user has not yet entered any data values. User will see the new row with default values defined on the underlying entity object. If the user never enters any data into any attribute of that initialized row, then it is as if the row never existed. When transaction is committed since the row is not part of the transaction's pending changes list, no INSERT statement will be performed and row will not be saved where as atleast one attribute in an initialized row is set, it changes the row status to STATUS_NEW and entity row is added to the transaction's list of pending changes and on commit new row will be permanently saved.
For more brevity with an example, please refer the following link:
Thanks to Andrejus Baranovskis
As per fusion guide:
What happens when you use Create?
// create a new row for the view object Row newRow = yourViewObject.createRow(); // mark the row as being "initialized", but not yet new newRow.setNewRowState(Row.STATUS_INITIALIZED);
When CreateInsert is used?
It performs this additional line of code to inert the row into the row set and make it available on the iterator.
// insert the new row into the view object's default rowset yourViewObject.insertRow(newRow);When CreateWithParams is used?
CreateWithParams does similar tasks as CreateInsert except that it gives the feasibility to define default values declaratively for the row attributes.
Suggested usages:
- With ADF forms you can use Create or CreateInsert.
- It is always safe to use CreateInsert when you have af:table as it will create a empty record and also puts it in recordset.
Transaction details:
When you create a row the transaction object associated with the current application module immediately takes note of the fact and the new entity row which gets created behind the view row is already part of the transaction's list of pending changes. As the status of new row will be marked as STATUS_INITIALIZED, it is removed from transaction's pending changes list and is considered a blank row in which the end user has not yet entered any data values. User will see the new row with default values defined on the underlying entity object. If the user never enters any data into any attribute of that initialized row, then it is as if the row never existed. When transaction is committed since the row is not part of the transaction's pending changes list, no INSERT statement will be performed and row will not be saved where as atleast one attribute in an initialized row is set, it changes the row status to STATUS_NEW and entity row is added to the transaction's list of pending changes and on commit new row will be permanently saved.
For more brevity with an example, please refer the following link:
Thanks to Andrejus Baranovskis
Comments
Post a Comment