By default, entity objects are created with the row state of STATUS_NEW, and BC4J adds them to its validation. In this case, any event that triggers a validation or database post sequence includes these entity objects.
As per OAF Model Coding Standards, always circumvent this behavior by explicitly calling the setNewRowState(STATUS_INITIALIZED) method on its containing ViewRowImpl immediately after you insert the newly created row. This sets the state of any associated entity objects to STATUS_INITIALIZED.
When you do this, BC4J removes the corresponding entity objects from the transaction and validation listener lists, so they will not be validated or posted to the database. As soon as the user makes a change (an attribute "setter" is called), the entity object's state changes to STATUS_NEW, and BC4J returns it to the validation/post lists. You can also call setNewRowState(STATUS_NEW) on the ViewRowImpl to change the state manually at any time.
Scenario 1: Row has been modified in the UI before submit. Row State could be anything.
- The RowState becomes New.
- ValidateEntity will get called before processFormRequest().
Scenario 2: Called row.setNewRowState(Row.STATUS_NEW) after inserting a new row. Row has not been modified from UI.
ValidateEntity will not get called before processFormRequest() but will get called on commit and postChanges.
Scenario 3: Called row.setNewRowState(Row.STATUS_INITIALIZED) after inserting a new row. Row has not been modified from UI.
- ValidateEntity will not get called before processFormRequest() or on commit or postChanges.
- The Row will be ignored by the Framework and removed from the Cache.
- Even the mandatory fields in the Entity Object are not checked.