Advertisement
pavadeli

AutoPPRSupport

May 14th, 2013
726
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.77 KB | None | 0 0
  1. package demo.view;
  2.  
  3. import java.util.Collection;
  4. import java.util.concurrent.atomic.AtomicInteger;
  5.  
  6. import oracle.adf.view.rich.activedata.ActiveModelContext;
  7. import oracle.adf.view.rich.activedata.BaseActiveDataModel;
  8. import oracle.adf.view.rich.event.ActiveDataEntry;
  9. import oracle.adf.view.rich.event.ActiveDataUpdateEvent;
  10.  
  11. import oracle.adfinternal.view.faces.activedata.ActiveDataEventUtil;
  12.  
  13.  
  14. public class AutoPPRSupport extends BaseActiveDataModel {
  15.   private static final Object[] STATIC_KEY = { 0 };
  16.  
  17.   private final AtomicInteger changeCounter = new AtomicInteger();
  18.  
  19.   protected void startActiveData(Collection<Object> collection, int i) {
  20.   }
  21.  
  22.   protected void stopActiveData(Collection<Object> collection) {
  23.   }
  24.  
  25.   public int getCurrentChangeCount() {
  26.     return changeCounter.get();
  27.   }
  28.  
  29.   /**
  30.    * Find out which component is currently evaluating EL to get at this attribute and remember the component for auto PPR.
  31.    *
  32.    * @param attributeName the name of the current attribute
  33.    */
  34.   public void rememberConsumerForAttribute(String attributeName) {
  35.     ActiveModelContext.getActiveModelContext().addActiveModelInfo(this, STATIC_KEY, attributeName);
  36.   }
  37.  
  38.   /**
  39.    * Refresh all components that use the attribute <code>attributeName</code>
  40.    * @param attributeName
  41.    * @param newValue
  42.    */
  43.   public void notifyConsumers(String attributeName, Object newValue) {
  44.     ActiveDataUpdateEvent event =
  45.       ActiveDataEventUtil.buildActiveDataUpdateEvent(ActiveDataEntry.ChangeType.UPDATE, changeCounter.incrementAndGet(),
  46.                                                      STATIC_KEY, null, new String[] { attributeName },
  47.                                                      new Object[] { newValue });
  48.     fireActiveDataUpdate(event);
  49.   }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement