- We can configure region, refreshes to invoke the task flow
- ADF region can invoke the task flow if the region is in active state
There are two type of refresh options
1) Default - Refreshes the region when the page loads and RefreshCondition=true.
2) ifNeeded - Refreshes the region if the value of the flow binding parameters changes.ifNeeded Option is set do not set the refresh condition
Shown above are the activation options for a region
Conditional -Refreshes the region if true
Differed - This is relevant if the the applications uses Faceletes XHTML pages
Immediate - Refresh the region immediately.Region refresh when the page displays
There are 3 ways of refreshing the region
1) Neither refresh or RefreshCondition specified ,Region refreshes the parent page displays
2) ADF region get refreshes when the RefreshConditions EL returns true .Refresh condition is independent of the changing value of binding parameters
3) ifNeeded is set for the Refresh option.Any change of value of binding parameters the refresh take place.ifNeeded selected no RefreshCondition specified.
Lets go through an example demonstrating the refresh condition
Create a task flow
Create a managed bean in pageflowscope of the task flow.
package
view;
import
java.util.HashMap;
import
java.util.Map;
import
oracle.adf.view.rich.context.AdfFacesContext;
public
class RegionMap {
private boolean refresh;
private String time;
public void setTime(String time) {
this.time = time;
}
public void setRefresh(boolean refresh) {
this.refresh = refresh;
}
public boolean isRefresh() {
String flag =(String)
AdfFacesContext.getCurrentInstance().getPageFlowScope().get("varFlag");
if ("true".equals(flag))
return true;
else
return false;
}
public RegionMap() {
super();
}
public Map getMyMap() {
Map map = new HashMap();
map.put("test1",
"test1");
map.put("test2",
"test2");
return map;
}
public String getTime() {
long t =System.currentTimeMillis();
System.out.println(t);
return "" + t;
}
public boolean refreshRegion() {
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("curTime",
System.currentTimeMillis());
return true;
}
public String testMeth() {
String flag=("true".equals((String)
AdfFacesContext.getCurrentInstance().getPageFlowScope().get("varFlag"))
? "false" :
"true");
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("varFlag",
flag);
System.out.println("Flag =" +
flag);
// Add event code here...
return null;
}
}Drag and drop the task flow to testRefreshRegion.jspx as a region and set the refresh condition as shown below
The code for testRefreshRegion.jspx is as below :
<?xml
version='1.0' encoding='UTF-8'?>
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page
contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document title="testRefreshRegion.jspx"
id="d1">
<af:form id="f1">
<af:region
value="#{bindings.regionRefresh1.regionModel}" id="r1"/>
<af:button text="button
1" id="b1"
action="#{pageFlowScope.RegionMap.testMeth}"/>
</af:form>
</af:document>
</f:view>
</jsp:root>
We need to add the managed bean to adfc-config.xml to visible to this page.Run the page. Click on the button based on the pageFlowScope variable = true the region will get refreshed.
ifNeeded and Binding variable change
Code for the testRefreshRegion.jspx is as below
<?xml
version='1.0' encoding='UTF-8'?>
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page
contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document
title="testRefreshRegion.jspx" id="d1">
<af:form id="f1">
<af:region
value="#{bindings.regionRefresh1.regionModel}" id="r1"/>
<af:button text="button
1" id="b1"
action="#{pageFlowScope.RegionMap.testMeth}"/>
<af:button text="button
2" id="b2"
action="#{pageFlowScope.RegionMap.testChange}"/>
</af:form>
</af:document>
</f:view>
Added button 2 here with action method as #{pageFlowScope.RegionMap.testChange}
Add testChange() method to the managed bean.
public String testChange() {
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("changeVar",
getTime());
// Add event code here...
return null;
}
Go to the page Def file of the testRefreshRegionPage.jspx and add parameters there .
<?xml
version="1.0" encoding="UTF-8" ?>
<pageDefinition
xmlns="http://xmlns.oracle.com/adfm/uimodel"
version="12.1.2.66.68" id="testRefreshRegionPageDef"
Package="view.pageDefs">
<parameters/>
<executables>
<variableIterator
id="variables"/>
<taskFlow id="regionRefresh1"
taskFlowId="/WEB-INF/regionRefresh.xml#regionRefresh"
activation="deferred"
xmlns="http://xmlns.oracle.com/adf/controller/binding"
Refresh="ifNeeded">
<parameters>
<parameter id="parameter"
value="#{pageFlowScope.changeVar}"/>
</parameters>
</taskFlow>
</executables>
<bindings/>
</pageDefinition>
Run the page and click on the 2nd button to see the region refreshes .
This comment has been removed by the author.
ReplyDeleteThis article is really helpful for understanding. But I have a doubt here for the Region Map Manage Bean. this manage bean is defined in the inner task flow refresh region, How the is action="#{pageFlowScope.RegionMap.testMeth}", which is belong to the inner taskflow manage bean, able to be called by the outer taskflow testRefreshRegion?
ReplyDeleteThank you! It help me a lot!
ReplyDeleteThanks! Can you send me example project?
ReplyDeleteThank you for the advise
ReplyDeleteActually i add entities in my adf screen ,now i changed another entity data is not refereshed in that page ,afer logout it will be refereshed data,can u please help me how can i referesh data in same page
ReplyDelete
ReplyDeleteIam so thrilled because of finding your alluring website here.Actually i was searching for Oracle ADF.Your blog is so astounding and informative too..Iam very happy to find such a creative blog. Iam also find another one by mistake while am searching the same topicOracle SOA.Thank you soo much..
Iam so thrilled because of finding your alluring website here.Actually i was searching for Oracle ADF.Your blog is so astounding and informative too..Iam very happy to find such a creative blog. Iam also find another one by mistake while am searching the same topicOracle SOA.Thank you soo much..
ReplyDeleteThank You and I have a dandy proposal: How To Budget House Renovation house renovation salary
ReplyDelete