@Test public void component_event_from_other_page() { String primaryPageName = "blocks/AppDisplay"; Page primaryPage = mockPage(); Page activePage = mockPage(); PageRenderQueue queue = mockPageRenderQueue(); PageActivationContextCollector collector = mockPageActivationContextCollector(); ComponentEventLinkEncoder linkEncoder = mockComponentEventLinkEncoder(); Link link = mockLink(); train_getRenderingPage(queue, activePage); train_getName(activePage, "order/View"); train_getName(primaryPage, primaryPageName); train_collectPageActivationContext(collector, "order/View", "x", "y"); EventContext pageActivationContext = new ArrayEventContext(typeCoercer, "x", "y"); EventContext eventContext = new ArrayEventContext(typeCoercer, 3, 5, 9); ComponentEventRequestParameters parameters = new ComponentEventRequestParameters("order/View", primaryPageName, "gnip.gnop", "myevent", pageActivationContext, eventContext); expect(linkEncoder.createComponentEventLink(parameters, true)).andReturn(link); replay(); LinkSource source = new LinkSourceImpl(queue, collector, typeCoercer, null, linkEncoder, null, null, emptyConfiguration); assertSame(source.createComponentEventLink(primaryPage, "gnip.gnop", "myevent", true, 3, 5, 9), link); verify(); }
public Link createComponentEventLink(Page page, String nestedId, String eventType, boolean forForm, Object... eventContext) { assert page != null; assert InternalUtils.isNonBlank(eventType); Page activePage = pageRenderQueue.getRenderingPage(); if (activePage == null) activePage = page; String activePageName = activePage.getName(); Object[] pageActivationContext = contextCollector.collectPageActivationContext(activePageName); ComponentEventRequestParameters parameters = new ComponentEventRequestParameters(activePageName, page.getName(), toBlank(nestedId), eventType, new ArrayEventContext(typeCoercer, pageActivationContext), new ArrayEventContext(typeCoercer, eventContext)); Link link = linkEncoder.createComponentEventLink(parameters, forForm); for (LinkCreationListener2 listener : listeners) listener.createdComponentEventLink(link, parameters); return link; }
LinkSourceImpl implements LinkSource, LinkCreationHub { public Link createComponentEventLink(Page page, String nestedId, String eventType, boolean forForm, Object... eventContext) { assert page != null; assert InternalUtils.isNonBlank(eventType); Page activePage = pageRenderQueue.getRenderingPage(); if (activePage == null) activePage = page; String activePageName = activePage.getName(); Object[] pageActivationContext = contextCollector.collectPageActivationContext(activePageName); ComponentEventRequestParameters parameters = new ComponentEventRequestParameters(activePageName, page.getName(), toBlank(nestedId), eventType, new ArrayEventContext(typeCoercer, pageActivationContext), new ArrayEventContext(typeCoercer, eventContext)); Link link = linkEncoder.createComponentEventLink(parameters, forForm); for (LinkCreationListener2 listener : listeners) listener.createdComponentEventLink(link, parameters); return link; } }
LinkSourceImpl implements LinkSource, LinkCreationHub { public Link createComponentEventLink(Page page, String nestedId, String eventType, boolean forForm, Object... eventContext) { assert page != null; assert InternalUtils.isNonBlank(eventType); Page activePage = pageRenderQueue.getRenderingPage(); if (activePage == null) activePage = page; String activePageName = activePage.getName(); Object[] pageActivationContext = contextCollector.collectPageActivationContext(activePageName); ComponentEventRequestParameters parameters = new ComponentEventRequestParameters(activePageName, page.getName(), toBlank(nestedId), eventType, new ArrayEventContext(typeCoercer, pageActivationContext), new ArrayEventContext(typeCoercer, eventContext)); Link link = linkEncoder.createComponentEventLink(parameters, forForm); for (LinkCreationListener2 listener : listeners) listener.createdComponentEventLink(link, parameters); return link; } LinkSourceImpl(PageRenderQueue pageRenderQueue, PageActivationContextCollector contextCollector,
            TypeCoercer typeCoercer, ComponentClassResolver resolver, ComponentEventLinkEncoder linkEncoder,
            RequestGlobals requestGlobals, RequestPageCache pageCache, List<LinkCreationListener2> configuration); }
LinkSourceImpl implements LinkSource, LinkCreationHub { public Link createComponentEventLink(Page page, String nestedId, String eventType, boolean forForm, Object... eventContext) { assert page != null; assert InternalUtils.isNonBlank(eventType); Page activePage = pageRenderQueue.getRenderingPage(); if (activePage == null) activePage = page; String activePageName = activePage.getName(); Object[] pageActivationContext = contextCollector.collectPageActivationContext(activePageName); ComponentEventRequestParameters parameters = new ComponentEventRequestParameters(activePageName, page.getName(), toBlank(nestedId), eventType, new ArrayEventContext(typeCoercer, pageActivationContext), new ArrayEventContext(typeCoercer, eventContext)); Link link = linkEncoder.createComponentEventLink(parameters, forForm); for (LinkCreationListener2 listener : listeners) listener.createdComponentEventLink(link, parameters); return link; } LinkSourceImpl(PageRenderQueue pageRenderQueue, PageActivationContextCollector contextCollector,
            TypeCoercer typeCoercer, ComponentClassResolver resolver, ComponentEventLinkEncoder linkEncoder,
            RequestGlobals requestGlobals, RequestPageCache pageCache, List<LinkCreationListener2> configuration); Link createComponentEventLink(Page page, String nestedId, String eventType, boolean forForm,
            Object... eventContext); Link createPageRenderLink(String pageName, boolean override, Object... pageActivationContext); LinkCreationHub getLinkCreationHub(); void addListener(LinkCreationListener listener); void addListener(LinkCreationListener2 listener); }
LinkSourceImpl implements LinkSource, LinkCreationHub { public Link createComponentEventLink(Page page, String nestedId, String eventType, boolean forForm, Object... eventContext) { assert page != null; assert InternalUtils.isNonBlank(eventType); Page activePage = pageRenderQueue.getRenderingPage(); if (activePage == null) activePage = page; String activePageName = activePage.getName(); Object[] pageActivationContext = contextCollector.collectPageActivationContext(activePageName); ComponentEventRequestParameters parameters = new ComponentEventRequestParameters(activePageName, page.getName(), toBlank(nestedId), eventType, new ArrayEventContext(typeCoercer, pageActivationContext), new ArrayEventContext(typeCoercer, eventContext)); Link link = linkEncoder.createComponentEventLink(parameters, forForm); for (LinkCreationListener2 listener : listeners) listener.createdComponentEventLink(link, parameters); return link; } LinkSourceImpl(PageRenderQueue pageRenderQueue, PageActivationContextCollector contextCollector,
            TypeCoercer typeCoercer, ComponentClassResolver resolver, ComponentEventLinkEncoder linkEncoder,
            RequestGlobals requestGlobals, RequestPageCache pageCache, List<LinkCreationListener2> configuration); Link createComponentEventLink(Page page, String nestedId, String eventType, boolean forForm,
            Object... eventContext); Link createPageRenderLink(String pageName, boolean override, Object... pageActivationContext); LinkCreationHub getLinkCreationHub(); void addListener(LinkCreationListener listener); void addListener(LinkCreationListener2 listener);  }