Forum Stats

  • 3,750,407 Users
  • 2,250,174 Discussions
  • 7,866,970 Comments

Discussions

Safe to store iterator ref in managed bean?

ILya Cyclone
ILya Cyclone Member Posts: 885 Bronze Badge

Hello.

Is it safe to save a reference to ADF iterator to an attribute in managed bean in standard java instance initializer (or constructor)?

Or should I be doing ADFUtils.findIterator("myIterator") each time to address iterator?

Does managed bean scope matter?


public class MyRequestOrViewScopeManagedBean {
  private final DCIteratorBinding myIter = ADFUtils.findIterator("myIterator");

  public void myActionListener(ActionEvent ae) {
  // do some stuff...
    myIter.executeQuery();
    Row row = myIter.getCurrentRow();
    // etc
  }
}


ADF 12.2.1.3

Best Answer

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,459 Red Diamond
    Accepted Answer

    It's not safe to store a reference to an iterator in a manager bean. The iterator can change during the lifecycle, e.g. if the application module is reused by another user. Once to get the application module back the reference is stale.

    Get the iterator from the binding each time is save.


    Timo


Answers

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,459 Red Diamond
    Accepted Answer

    It's not safe to store a reference to an iterator in a manager bean. The iterator can change during the lifecycle, e.g. if the application module is reused by another user. Once to get the application module back the reference is stale.

    Get the iterator from the binding each time is save.


    Timo


  • ILya Cyclone
    ILya Cyclone Member Posts: 885 Bronze Badge

    Thank you Timo.

  • ILya Cyclone
    ILya Cyclone Member Posts: 885 Bronze Badge

    @Timo Hahn On the other hand, application module mustn't be passivated during a request (unless I call .postChanges()), right? So storing a reference in RequestScope of BackingBeanScope should be safe?

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,459 Red Diamond

    No, postChanges() has nothing to do with passivation. The framework decides when to passivated an application module. If there are uncommitted data the data is stored together with other information and recreated once the application module is used again by the user.


    If you store the iterator in a request scope or backing bean scope bean, what's the point?

    The timespan the bean lives is very short anyway. Why not get it from the bindings?


    Timo