Pages

Saturday, January 10, 2009

Calling an insert edit Task Flow

Inspired by a great article of Frank and Steve about how to cancel an edit Task Flow where Frank is using adfm savepoints to achieve this. In this example I rebuild my dynamic regions example and added the a create / insert Task Flow. This TF start a new transaction ( So I don't need to use an adfm savepoint) and this transaction which will be rollbacked by an abort. The create edit TF of Steve and Frank is using the same viewobject iterator in the main page and the create edit TF. The TF I build can be used everywhere just pass the departmentId to this TF. If you use the shared datacontrol option then the main page detects the update and refreshes the deparments in the tree and fragment, It also works in Isolated mode but then you can not see the department changes. In this example I call this TF from a tree (unbounded TF) and from a page fragment (Bounded).
Here the create edit department Task Flow is called from a page fragment.
The create / edit Task Form.
It start with a router which eveluates the department primary key input parameter. If it has the value 0 then the createinsert operation on the department iterator is called else the setCurrentRowWithKeyValue operation is called.
Here is picture of the router parameters ( this is the default activity) where we evaluates the input.


In the unbounded TF there are two control flow cases between the create edit TF and the view.


Here is the TF of the department page fragment. Here I don't have a return flow case because this is fragment. The fragment can not be replaced by a TF. We can only open the create edit TF in a dialog mode and the user can close the TF and return to the page with the fragment.
To achieve this we need to select the TF call in the page fragment Task Flow and select the run as dialog option.

The second step is to change the button which calls the action. Go to the page fragment page and select the button where we select the useWindow option. Now the TF is opened in a popup.


To pass the department primary key value to the create edit TF we need to use an input parameter
In the behaviour option of the Task Flow we change the transaction option to new-transaction so we call just do a rollback or commit when we leave the TF.

Here is the example workspace

2 comments:

  1. Nice article !

    I have a couple questions :

    -So, whole sense of Isolated mode is that task flow Always Begins a New Transaction ? Or I am wrong ?

    -And, can you explain in more details the following section:

    "If you use the shared datacontrol option then the main page detects the update and refreshes the deparments in the tree and fragment, It also works in Isolated mode but then you can not see the department changes."

    So, if this works in Isolated mode (detecting, updating and refreshing depts),then, why you cannot see those changes ? And what to do in order for changes to become visible ? Re-execute VO queries, refresh UI controls,... ?

    Regards,...

    ReplyDelete
  2. Hi,

    Whole sense of Isolated mode is that task flow Always Begins a New transaction.
    Yep that is a side effect, but more important with adf bc that you dont have any problems with iterators. For example. when you do getCurrentRow on a iterator every TF will see this currentRow. And in UIshell where you can open the same TF many times ( dont want to see the same record in every TF )

    In Isolated mode is a PPR event or refresh of a iterator enough ( add PPR on the iterator )

    thanks

    ReplyDelete