@Test public void nested_element_within_page() { RequestPageCache cache = mockRequestPageCache(); Page page = mockPage(); ComponentPageElement element = mockComponentPageElement(); Component component = mockComponent(); ComponentClassResolver resolver = mockComponentClassResolver(); train_get(cache, PAGE_NAME, page); train_getComponentElementByNestedId(page, NESTED_ELEMENT_ID, element); train_getComponent(element, component); replay(); ComponentSource source = new ComponentSourceImpl(cache, resolver, null); assertSame(source.getComponent(PAGE_NAME + ":" + NESTED_ELEMENT_ID), component); verify(); }
public Component getComponent(String completeId) { assert InternalUtils.isNonBlank(completeId); int colonx = completeId.indexOf(':'); if (colonx < 0) { Page page = pageCache.get(completeId); return page.getRootComponent(); } String pageName = completeId.substring(0, colonx); Page page = pageCache.get(pageName); String nestedId = completeId.substring(colonx + 1); String mixinId = null; int dollarx = nestedId.indexOf("$"); if (dollarx > 0) { mixinId = nestedId.substring(dollarx + 1); nestedId = nestedId.substring(0, dollarx); } ComponentPageElement element = page.getComponentElementByNestedId(nestedId); if (mixinId == null) return element.getComponent(); ComponentResources resources = element.getMixinResources(mixinId); return resources.getComponent(); }
ComponentSourceImpl implements ComponentSource { public Component getComponent(String completeId) { assert InternalUtils.isNonBlank(completeId); int colonx = completeId.indexOf(':'); if (colonx < 0) { Page page = pageCache.get(completeId); return page.getRootComponent(); } String pageName = completeId.substring(0, colonx); Page page = pageCache.get(pageName); String nestedId = completeId.substring(colonx + 1); String mixinId = null; int dollarx = nestedId.indexOf("$"); if (dollarx > 0) { mixinId = nestedId.substring(dollarx + 1); nestedId = nestedId.substring(0, dollarx); } ComponentPageElement element = page.getComponentElementByNestedId(nestedId); if (mixinId == null) return element.getComponent(); ComponentResources resources = element.getMixinResources(mixinId); return resources.getComponent(); } }
ComponentSourceImpl implements ComponentSource { public Component getComponent(String completeId) { assert InternalUtils.isNonBlank(completeId); int colonx = completeId.indexOf(':'); if (colonx < 0) { Page page = pageCache.get(completeId); return page.getRootComponent(); } String pageName = completeId.substring(0, colonx); Page page = pageCache.get(pageName); String nestedId = completeId.substring(colonx + 1); String mixinId = null; int dollarx = nestedId.indexOf("$"); if (dollarx > 0) { mixinId = nestedId.substring(dollarx + 1); nestedId = nestedId.substring(0, dollarx); } ComponentPageElement element = page.getComponentElementByNestedId(nestedId); if (mixinId == null) return element.getComponent(); ComponentResources resources = element.getMixinResources(mixinId); return resources.getComponent(); } ComponentSourceImpl(RequestPageCache pageCache, ComponentClassResolver resolver, RequestGlobals globals); }
ComponentSourceImpl implements ComponentSource { public Component getComponent(String completeId) { assert InternalUtils.isNonBlank(completeId); int colonx = completeId.indexOf(':'); if (colonx < 0) { Page page = pageCache.get(completeId); return page.getRootComponent(); } String pageName = completeId.substring(0, colonx); Page page = pageCache.get(pageName); String nestedId = completeId.substring(colonx + 1); String mixinId = null; int dollarx = nestedId.indexOf("$"); if (dollarx > 0) { mixinId = nestedId.substring(dollarx + 1); nestedId = nestedId.substring(0, dollarx); } ComponentPageElement element = page.getComponentElementByNestedId(nestedId); if (mixinId == null) return element.getComponent(); ComponentResources resources = element.getMixinResources(mixinId); return resources.getComponent(); } ComponentSourceImpl(RequestPageCache pageCache, ComponentClassResolver resolver, RequestGlobals globals); Component getComponent(String completeId); Component getPage(String pageName); Component getPage(Class pageClass); Component getActivePage(); }
ComponentSourceImpl implements ComponentSource { public Component getComponent(String completeId) { assert InternalUtils.isNonBlank(completeId); int colonx = completeId.indexOf(':'); if (colonx < 0) { Page page = pageCache.get(completeId); return page.getRootComponent(); } String pageName = completeId.substring(0, colonx); Page page = pageCache.get(pageName); String nestedId = completeId.substring(colonx + 1); String mixinId = null; int dollarx = nestedId.indexOf("$"); if (dollarx > 0) { mixinId = nestedId.substring(dollarx + 1); nestedId = nestedId.substring(0, dollarx); } ComponentPageElement element = page.getComponentElementByNestedId(nestedId); if (mixinId == null) return element.getComponent(); ComponentResources resources = element.getMixinResources(mixinId); return resources.getComponent(); } ComponentSourceImpl(RequestPageCache pageCache, ComponentClassResolver resolver, RequestGlobals globals); Component getComponent(String completeId); Component getPage(String pageName); Component getPage(Class pageClass); Component getActivePage();  }