Hi All,
In this post I am going to explain some
tricky way to refresh the taskflow that doesn't have contextual event and also
isolated data control(datacontrol not shared). There is another way explained
by Andreju's communicating between regions without contextual events.
download app here
Use case :
Lets consider the search and showing results use case. I have two
taskflows, one is Search Taskflow and for showing the results I have separate
Taskflow. For searching the employees in the particular department, lets have search field in the search taskflow
and results taskflow should show the employees in the departments.
For example, If the page contains multiple
taskflows, those will be refreshed from one consumer class. i.e., on click of
search you can refresh the multiple taskflows for those doesn't have the
events.
---
1. Create two taskflow Search TF and ResultsTF with
input parameters on both. In my case I am passing the helper class as parameter
such as SearchHelper and ResultsHelper
2. Now we are going to use the contextual event for
the SearchTF, for that create a producer and launch the event on click of
search button on the SearchTF and my ResultsTF doesn't have any events but has
one helper class as input parameter
3. Results bean in the Results page has the method that filters the
records based on the search key(department id). And also , in the constructor I
am getting the helper parameter object.
and I am reading the viewobject onload and setting
the vo into my ResulttsHelper class.
So,
at very first time when the taskflow loads, I am getting the vo and setting it
into the ResulttsHelper.
To avoid using code in constructor you can use Method
call activity and mark it as default activity so that onload of the taskflow it
will get executed.
Now here the trick helps, similarly I am
setting the bean instance also in my ResulttsHelper class like below using one
of the binded getter method in the Results bean,
4. Now drag drop two taskflows in the main
page and and consume the event using a consumer class.
SearchTF event consumer in
mainpage.jspx page definition
5. The consumer finally calls the method
inside the ResultsTF. The highlighted
line below is accessed gives the instance of the Results bean which is been set
o load, refer Step 3 image.
The results table is filtered and refreshed inside the method refreshTF, also you can refresh the table from the consumer be directly accessing the components like below,
AdfFacesContext.getCurrentInstance().addPartialTarget(rhelper.getBackingBean().getTable());
And finally the result looks like this,
Download sample here
How to use contextual events ?
http://andrejusb.blogspot.in/2011/02/adf-region-communication-data-exchange.html
http://andrejusb.blogspot.in/2010/10/contextual-events-framework-and-adf-11g.html
http://andrejusb.blogspot.in/2010/10/contextual-events-framework-and-adf-11g.html
No comments:
Post a Comment