ADF lifecycle phases difference - oracle-adf

Difference between ADF initContext and prepareModel,since both preparing data by executing buisness service making it available through binding container which is a Map object.

ADF initContext and prepareModel,since both preparing data by executing buisness service
This is not quite correct. The initContext sets up the BindingContext, which ensures the content of DataBindings.cpx is initialized and the binding container for the page to be prepared. The prepareModel is an execution point for data queries.
The other execution point, as Timo's answer shows, is PrepareRender. Recommendation though is to keep the iterator default setting, which is "deferred" in which case only those iterators are refreshed and queried that have UI dependency.

The ADF model life cycle phases:
initContext sets up the life cycle, working out what PageDefs to load.
prepareModel creates the bindings object and adds it to the HTTP request. Parameters are also evaluated at this point.
applyInputValues processes the values posted from the page and builds up an internal list of bindings to update and methods to execute as required.
validateInputValues applies the client-side validators to the list of updates presented by the applyInputValues phase. These validators are defined as nested f:validator and af:convertNumber components within an input component.
processUpdateModel sends the validated changes to bound objects to the model layer.
validateModelUpdates manages validation errors from the Model layer.
processComponentEvents processes any listeners and action events queued up from the applyInputValues phase.
metadataCommit manages part of the runtime customization capabilities of the framework.If the user has customized the page in some way such as moving components on the screen or adding in task flows via WebCenter, then those personalizations to the screen are saved away to the metadata repository (MDS) at this point.
prepareRender is the last phase to execute before the page is displayed.
Note that in some situations (such as a modal dialog), the following code will not necessarily fire after the page has been rendered:
public void afterPhase(PagePhaseEvent pagePhaseEvent) {
if (pagePhaseEvent.getPhaseId() == Lifecycle.PREPARE_RENDER_ID) {
injectRedirect();
}
}
This prevents the server code from being able to examine the af:document immediately after the document is rendered. For example the following will fail because there is no document available:
return context.getViewRoot().getChildren().get(0).getClientId().equals("doc0");

Related

Coalescing Flux Actions

This is a detailed Flux Architecture question.
Say I have a resource that gets asynchronously prepared. Let's take User Data as an example.
There are multiple different ways to get this user data - in our example it may be that it requires a few different subsequent queries to generate from the server or is stored locally as a whole.
Case 1:
User data needs sequential steps. Fire USER_DATA_1_SUCESS, USER_DATA_2_SUCCESS. Other stores listen for USER_DATA_2_SUCCESS.
Case 2:
User Data is locally available as a whole. Fire a USER_DATA_READY action.
I'm trying to figure out how to go from a linear state completion (USER_DATA_2_SUCESS) to a resource ready event (USER_DATA_READY) in the stores. I can't call USER_DATA_READY directly from the stores - I get a can't call action in the middle of dispatch error. At the same time I want granularity - I want to control the different stages of putting the data together.
I'd like to have one way to condense these calls with good design. The option I can think of is:
Add a convenience 'Ready' function in a client class that is visible to the store. Call it with a tiny timeout in the stores callback for USER_DATA_2_SUCCESS.
Can anyone suggest a better flow?

Oracle ADF: Refresh Form data

I am developing a web app using Oracle ADF. I have a bounded task flow. In that I have a search page like below.
I have created the above two forms using view object data controls.
Searching is performing well. But my problem is when I go some where else in my application using menus provided left side and come back to the search page , the page is not getting refreshed. I am getting a search page that contains old search results. At this point of time if I am trying to make any changes am getting some error called "Another user with this id already modifed data ....". After this error my app is not running. Means what ever am trying to do its showing the same error.
So I need to make this: "When ever the user come to this form, He should get fresh form. It should not contain old search results.
Please help me. How do I achieve this.
Thank you.
There are 2 ways of doing it:
1) Set your task flow as ISOLATED, from Task Flow Overview tab -> Behaviour -> Share Data Control with calling task flow -> unchecked (or isolated, if you are using JDev 12c)
This will ensure you always start FRESH when accessing the page, but it will potentially create a performance overhead because entire View Object cache will be recreated (requeried) on page load. Nevertheless, it is the quickest solution.
2) You may create a default Method Call Activity in your task flow from where you may call a AM's custom method that resets the view criteria. The method will be placed on application module's implementation class and it may look like this:
public void initTaskFlow() {
this.getViewObject1().executeEmptyRowSet();
}
This will clean the result data. If you want to reset the querying parameters as well, you can use this example:
http://www.jobinesh.com/2011/04/programmatically-resetting-and-search.html
When you made any changes to any viewObject then excute this viewObject to match entity state and viewState , i think excuting viewObject will solve your issue
Ashish

AngularJS: Commit/Rollback model based on $resource

I'm trying to find a generic solution to commit/rollback a model alongside ng-resource.
When to commit/save model:
Successful http write methods (PUT, POST, PATCH).
When to rollback/reset model:
Failing http write methods.
User deciding to cancel their local changes (before PUT).
I've found pieces of this solution scattered, but no comprehensive strategy.
My initial strategy was to make use of the default ng-resource cache. Controller starts with GETting an item. If a subsequent PUT/POST/PATCH failed (caught either in the controller's promise, or in the $resource.<write_method>'s interceptor.responseError, re-run the GET that first got the object, and replace my model with that, as on initial load. However, this doesn't help if there's a successful PUT, followed by a failed one, because I'd be replacing my model with a stale object. The same problem occurs when a user tries to cancel their form changes before submitting... the last successful GET may be stale.
I've got a model with ~10 properties, and multiple <form>s (for html/design's sake) that all interact with this one object that gets PUT upon any of the forms being submitted:
{'location_id': 1234,
'address': {
'line1': '123 Fake St'}
...
},
'phone': '707-123-4567',
...
}
Models already have nice rollback features, but getting ng-resource to touch them seems tricky, and I really want to reset the entire object/model. Using a custom cache alongside my $resource instance seems like a decent way to go, but is equally tricky to give user-interaction a way to rollback. Another idea was to store a separate object when loading into scope: $scope.location = respData; $scope._location = angular.copy(respData); that I could load from when wanting to roll back, by way of $scope.location = $scope._location;, but I really don't want to clutter my controllers site-wide with these shadow objects/functions (DRY).

Stopping the publish flow in an event or disabling the publish button

I wondering if it's possible to stop the publish flow in an event.
I want to check some properties in the code-behind before I let the user publish the object.
You can use the static DataEvents<T> class which has a OnStoreChanged event you can hook into.
Example use from the api page:
DataEvents<IMyDataType>.OnStoreChanged += new StoreEventHandler(DataEvents_OnStoreChanged);
...
void DataEvents_OnStoreChanged(object sender, StoreEventArgs storeEventArgs)
{
if (!storeEventArgs.DataEventsFired)
{
// an external update event happened - DataEvents_OnBeforeAdd not fired
// here a complete cache flush could be done
}
}
If you care about page publishing you would have to use DataEvents<IPage> and check the StoreEventArgs for the PublicationScope which should tell you whether this was a publishing event or not.
From the documentation of DataEvents<T>.OnStoreChanged:
This event is fired after changes has happened to the Composite C1 data store. This may be atomic actions or a larger change to the underlying data store. The StoreEventArgs class describe the change in broad terms, including a flag indicating is detailed data event have been raised or not. You can use this event as a simple way to react to data changes (like clearing a cache) or you can mix this with atomic data events (add, delete, update) to make a build a more advanced cache. You should listen to this event in order to support scale out across multiple servers, since this event is meant to be signaled when changes happen on another server. In such situations detailed data events will not fire on other machines.
If you care about exactly what data was changed in the event, you have to use the other events of the DataEvents<T>class like OnAfterUpdate and get this information from the DataEventArgs.

Detecting async function calls completion in silverlight

Say,there is a requirement that a customer object is loaded from the db to a silverlight application, so that the customer details are shown in the UI. We need to detect if the user is changing any data in the UI.
We are listening to property changed notifications from the view model. However, when the notifications are result of property change as part of the loading process we have to discard it.
class CustomerLoader
{
Helper helerobj;
Address addressobj;
Profile profileobj;
void LoadFromDb()
{
helperobj.Load();
addressobj.Load();
profileobj.Load();
//start listening after the loading finished
this.propertychanged += new PropertyChangedEventHandler(handlepropertychanged);
}
The trouble with this is the inner objects might be calling asynchronous functions which might set properties. So by the time we started the property change listening, the loading might not have been finished.
We need to know when the loading is actually done. As of now we are asking the developers who are developing the inner object classes to accept a callback in the parameter which they should call when the function is finished.
Is there any other way to do it?
You want nothing but a really classic asynchronous objet loading.
So yes, the only solution is to ask developers working on the loading to propose an asynchronous function. Now you hav several solution to achieve asynchronicity in Silverlight.
You could either provide a callback as you do, or use async and await to manage your asynch task as explain here: http://10rem.net/blog/2012/05/22/using-async-and-await-in-silverlight-5-and-net-4-in-visual-studio-11-with-the-async-targeting-pack

Resources