@Test public void page_does_not_handle_passivate_event() { String pageName = "mypage"; ComponentModel model = mockComponentModel(); ComponentModelSource modelSource = mockComponentModelSource(); RequestPageCache pageCache = mockRequestPageCache(); expect(modelSource.getPageModel(pageName)).andReturn(model); expect(model.handlesEvent(EventConstants.PASSIVATE)).andReturn(false); replay(); PageActivationContextCollector collector = new PageActivationContextCollectorImpl(coercer, pageCache, modelSource); Object[] actual = collector.collectPageActivationContext(pageName); assertEquals(actual.length, 0); }
public Object[] collectPageActivationContext(String pageName) { Boolean hasHandler = cache.get(pageName); if (hasHandler == null) { ComponentModel model = modelSource.getPageModel(pageName); hasHandler = model.handlesEvent(EventConstants.PASSIVATE); cache.put(pageName, hasHandler); } if (!hasHandler) return EMPTY; Page page = requestPageCache.get(pageName); ComponentPageElement element = page.getRootElement(); final Holder<Object[]> holder = Holder.create(); ComponentEventCallback callback = new ComponentEventCallback() { public boolean handleResult(Object result) { holder.put(typeCoercer.coerce(result, Object[].class)); return true; } }; element.triggerEvent(EventConstants.PASSIVATE, null, callback); if (!holder.hasValue()) return EMPTY; return holder.get(); }
PageActivationContextCollectorImpl implements PageActivationContextCollector { public Object[] collectPageActivationContext(String pageName) { Boolean hasHandler = cache.get(pageName); if (hasHandler == null) { ComponentModel model = modelSource.getPageModel(pageName); hasHandler = model.handlesEvent(EventConstants.PASSIVATE); cache.put(pageName, hasHandler); } if (!hasHandler) return EMPTY; Page page = requestPageCache.get(pageName); ComponentPageElement element = page.getRootElement(); final Holder<Object[]> holder = Holder.create(); ComponentEventCallback callback = new ComponentEventCallback() { public boolean handleResult(Object result) { holder.put(typeCoercer.coerce(result, Object[].class)); return true; } }; element.triggerEvent(EventConstants.PASSIVATE, null, callback); if (!holder.hasValue()) return EMPTY; return holder.get(); } }
PageActivationContextCollectorImpl implements PageActivationContextCollector { public Object[] collectPageActivationContext(String pageName) { Boolean hasHandler = cache.get(pageName); if (hasHandler == null) { ComponentModel model = modelSource.getPageModel(pageName); hasHandler = model.handlesEvent(EventConstants.PASSIVATE); cache.put(pageName, hasHandler); } if (!hasHandler) return EMPTY; Page page = requestPageCache.get(pageName); ComponentPageElement element = page.getRootElement(); final Holder<Object[]> holder = Holder.create(); ComponentEventCallback callback = new ComponentEventCallback() { public boolean handleResult(Object result) { holder.put(typeCoercer.coerce(result, Object[].class)); return true; } }; element.triggerEvent(EventConstants.PASSIVATE, null, callback); if (!holder.hasValue()) return EMPTY; return holder.get(); } PageActivationContextCollectorImpl(TypeCoercer typeCoercer, RequestPageCache requestPageCache,
                                              ComponentModelSource modelSource); }
PageActivationContextCollectorImpl implements PageActivationContextCollector { public Object[] collectPageActivationContext(String pageName) { Boolean hasHandler = cache.get(pageName); if (hasHandler == null) { ComponentModel model = modelSource.getPageModel(pageName); hasHandler = model.handlesEvent(EventConstants.PASSIVATE); cache.put(pageName, hasHandler); } if (!hasHandler) return EMPTY; Page page = requestPageCache.get(pageName); ComponentPageElement element = page.getRootElement(); final Holder<Object[]> holder = Holder.create(); ComponentEventCallback callback = new ComponentEventCallback() { public boolean handleResult(Object result) { holder.put(typeCoercer.coerce(result, Object[].class)); return true; } }; element.triggerEvent(EventConstants.PASSIVATE, null, callback); if (!holder.hasValue()) return EMPTY; return holder.get(); } PageActivationContextCollectorImpl(TypeCoercer typeCoercer, RequestPageCache requestPageCache,
                                              ComponentModelSource modelSource); @PostInjection void setupInvalidation(@ComponentClasses InvalidationEventHub invalidationEventHub); Object[] collectPageActivationContext(String pageName); }
PageActivationContextCollectorImpl implements PageActivationContextCollector { public Object[] collectPageActivationContext(String pageName) { Boolean hasHandler = cache.get(pageName); if (hasHandler == null) { ComponentModel model = modelSource.getPageModel(pageName); hasHandler = model.handlesEvent(EventConstants.PASSIVATE); cache.put(pageName, hasHandler); } if (!hasHandler) return EMPTY; Page page = requestPageCache.get(pageName); ComponentPageElement element = page.getRootElement(); final Holder<Object[]> holder = Holder.create(); ComponentEventCallback callback = new ComponentEventCallback() { public boolean handleResult(Object result) { holder.put(typeCoercer.coerce(result, Object[].class)); return true; } }; element.triggerEvent(EventConstants.PASSIVATE, null, callback); if (!holder.hasValue()) return EMPTY; return holder.get(); } PageActivationContextCollectorImpl(TypeCoercer typeCoercer, RequestPageCache requestPageCache,
                                              ComponentModelSource modelSource); @PostInjection void setupInvalidation(@ComponentClasses InvalidationEventHub invalidationEventHub); Object[] collectPageActivationContext(String pageName);  }