As you know we are using Oracle ADF tables to represent data at database tables, views, etc... When application loads tables load data from db and displays those. But if data is changed or new added or existing data get deleted..?? Then we need a mechanism to display the updated data.
We can use ADF Poll for this. Then we can use poll event to refresh table data after every time period.
We can use ADF Poll for this. Then we can use poll event to refresh table data after every time period.
Steps:
- Insert Poll inside “panelHeader” in which table is located
- Set poll interval from poll properties- This is the time gap for every refresh. for Ex: if you have set poll interval as 5 seconds table data will be refreshed after every 5 seconds.
If you want you can take this value from template properties.
Value you entered: #{manage_Template.dataRefreshRate}
(This is used to get the refresh value by using the method in manage_Template) - Set partial triggers from poll properties - Here you can specify the table which you want to get refreshed. for Ex: table1
- Set partial triggers from ADF table - Give the poll id for this field.
Table --> Behavior --> Partial Triggers --> Set poll id here - Set Poll Listener from poll properties - This is the most important mapping which links what is the action has to be taken out when poll event triggers
Type a method e.g.: refreshSPIntentionTab ()
Press enter
(Method is created in .java file) - Add the below code to the poll listener method using appropriate VOIterators
There are three stages at this code.
STAGE 1:
If you want only to refresh the table you can use the current method. At this method you can’t maintain the current row position after table refresh.
public void refreshSPIntentionTab (PollEvent pollEvent) {
FacesContext fctx = FacesContext.getCurrentInstance();
ValueBinding dcb = fctx.getApplication().createValueBinding("#{bindings}");
DCBindingContainer bindings1 = (DCBindingContainer) dcb.getValue(fctx);
if(bindings1!=null){
DCIteratorBinding dciter = bindings1.findIteratorBinding("DeliveryIntentionsSPApprovVO1Iterator ");
if(dciter!=null){
if(dciter.getCurrentRow()!=null){
dciter.executeQuery();
}
}
}
}
STAGE 2:
If you want to refresh the table and maintain the current row position after the table refresh.... We can apply this only for a single table; not for master-detail tables.
public void refreshSPIntentionTab (PollEvent pollEvent) {
FacesContext fctx = FacesContext.getCurrentInstance();
ValueBinding dcb = fctx.getApplication().createValueBinding("#{bindings}");
DCBindingContainer bindings1 = (DCBindingContainer)dcb.getValue(fctx);
if (bindings1 != null) {
DCIteratorBinding dciter = bindings1.findIteratorBinding("DeliveryIntentionsSPApprovVO1Iterator ");
if (dciter != null) {
if (dciter.getCurrentRow() != null) {
Key current_row_key = dciter.getCurrentRow().getKey();
dciter.executeQuery();
if (current_row_key != null) {
try {
dciter.setCurrentRowWithKey(current_row_key.toStringFormat(true));
} catch (Exception ex) {
System.out.println("Exception in current_row_key");
}
}
}
}
}
}
STAGE 3:
If you want to maintain the current row position of master-detail tables after the table refresh, use the following methods.
// for the master table refresh
public void refreshSPIntentionTab (PollEvent pollEvent) {
FacesContext fctx = FacesContext.getCurrentInstance();
ValueBinding dcb = fctx.getApplication().createValueBinding("#{bindings}");
DCBindingContainer bindings1 = (DCBindingContainer)dcb.getValue(fctx);
DCIteratorBinding it = bindings1.findIteratorBinding("DeliveryIntentionsSPApprovVO1Iterator");
ViewObject vo = it.getViewObject();
Row row = vo.getCurrentRow();
Key key = row.getKey();
int rangePosition = vo.getRangeIndexOf(row);
int rangeStart = vo.getRangeStart();
if(rangePosition==(-1)){
rangePosition=rangePositionCommon;
rangeStart=rangeStartCommon;
}
vo.executeQuery();
vo.setRangeStart(rangeStart);
Row[] rows = vo.findByKey(key, 1);
if (rows != null && rows.length == 1) {
vo.scrollRangeTo(rows[0], rangePosition);
vo.setCurrentRowAtRangeIndex(vo.getRangeIndexOf(rows[0]));
rangePositionCommon=rangePosition;
rangeStartCommon=rangeStart;
}
}
// for the detail table refresh
public void refreshSPIntentionTab (PollEvent pollEvent) {
FacesContext fctx = FacesContext.getCurrentInstance();
ValueBinding dcb = fctx.getApplication().createValueBinding("#{bindings}");
DCBindingContainer bindings1 = (DCBindingContainer) dcb.getValue(fctx);
if(bindings1!=null){
DCIteratorBinding dciter = bindings1.findIteratorBinding("DeliveryIntentionsSPApprovVO1Iterator ");
if(dciter!=null){
if(dciter.getCurrentRow()!=null){
dciter.executeQuery();
}
}
}
}
Now all the setup processes are completed. Please check your new functionality.
Cheers..!!
There are lots of information about oracle have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get to the next level in oracle. Thanks for sharing this.
ReplyDeleteOracle Training in Chennai | Oracle Course in Chennai | hadoop training in chennai
Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.
ReplyDeleteRegards,
cognos Training in Chennai
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
ReplyDeleteHadoop Training Institute In chennai
amazon-web-services-training-institute-in-chennai
I am really happy with your blog because your article is very unique and powerful for new reader.
ReplyDeleteselenium training in chennai
selenium training in bangalore
selenium training in Pune
Selenium Online Training
selenium training in chennai
selenium training in bangalore
selenium training in chennai
Selenium Online Training
Selenium Online Training
selenium training in tambaram
selenium training in annanagar
selenium training in velachery
selenium training in OMR
selenium training in marathahalli
selenium training in btm
selenium training in rajajinagar
selenium training in pune
let others light their candles with this.. I'm glad :)
ReplyDeleteThanks for sharing such an informative blog.Awaiting for your next update.
ReplyDeleteSelenium Training in chennai | Selenium Training in annanagar | Selenium Training in omr | Selenium Training in porur | Selenium Training in tambaram | Selenium Training in velachery
Thanks for such a wonderful help...Keep posting...This Blogs are a part of others Enhancement in Their careers...Well Done works
ReplyDeleteJava training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery
Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog.thanks!!
ReplyDeleteandroid training in chennai
android online training in chennai
android training in bangalore
android training in hyderabad
android Training in coimbatore
android training
android online training