Friday, July 15, 2011

Force Iterator refresh with EJB Web Service DataControl

ADF Faces with EJB 3.0 Web services is among famous combination architects are committing to. It has its own winning and loosing grounds over ADFBc.
One of the issues that I found many developers struggle with is refresh of IteratorBinding, especially in scenario when repeated calls are made to same method binding. We found that sometimes, for reason yet to be discovered, iterator is not loaded with the fresh data.
One approach toward this issue is making use of Refresh Property which could be set to various values in drop down like always, default, ifNeeded, never etc. This is declarative approach and you should try it before attempting programmatically.
However if this doesn't works you can try invalidateCache() on the DCIteratorBinding. This too could be set declarative by setting cache result to false.. but some developers didn't had positive experience including me.


  1. You can make it always refresh by disable cache in page def and make it always to refresh, but in case u make selection with af:table the row.key will be generated each time so u should be careful using it

  2. Yes. Setting refresh to always may be expensive, we may or may not have luxury to do that.

  3. As far as "didn't have positive results", I would get an infinite loop of calls to refresh the data in a select one list box if I set CacheResults to "false". So it want back to the default of "true". I tried all values for "Refresh" did not refresh my list regardless of any ppr/partial triggers. I created an invokeAction that didn't work either. All of these approaches came directly from Oracle's ADF developer's guide. And none worked.

    However, I luckily stumbled on Amit's post here. Thank you Amit. It worked with no side effects. Here is a bit more detail in case it helps someone else:

    My action listener method of a command button that adds another item in the back end that should be reflected in a select one listbox:

    FacesContext fc = FacesContext.getCurrentInstance();
    ELContext elctx = fc.getELContext();
    ExpressionFactory elFactory = fc.getApplication().getExpressionFactory();
    MethodExpression methodExpr = elFactory.createMethodExpression(elctx,
    null, new Class[]{});
    Object returnValue = methodExpr.invoke(elctx,new Object[]{});
    DCBindingContainer cont = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingFactory();
    DCIteratorBinding iteratorBinding = (DCIteratorBinding)cont.get("allWorkAreaGroupsIterator");

  4. That is good website in blogspot. SEO is a very importtant our website for Build the link.I also provided this service plz visit my site free seo Analysis Web OptimiA is a india based SEO service.