@Override public Object createObject() { return componentSource.getPage(injectedPageName); } });
private InternalFormSupport createInternalFormSupport(String formClientId, String formComponentId, ComponentActionSink actionSink) { // Kind of ugly, but the only way to ensure we don't have name collisions on the // client side is to force a unique id into each name (as well as each id, but that's // JavaScriptSupport's job). It would be nice if we could agree on the uid, but // not essential. String uid = Long.toHexString(System.nanoTime()); IdAllocator idAllocator = new IdAllocator("_" + uid); Component formComponent = componentSource.getComponent(formComponentId); CaptureResultCallback<InternalFormSupport> callback = CaptureResultCallback.create(); // This is a bit of a back-door to access a non-public method! formComponent.getComponentResources().triggerEvent("internalCreateRenderTimeFormSupport", new Object[] { formClientId, actionSink, idAllocator }, callback); return callback.getResult(); } }
Component activePage = componentSource.getActivePage();
component = source.getComponent(componentId);
@Test public void get_active_page_before_known() { RequestGlobals globals = mockRequestGlobals(); expect(globals.getActivePageName()).andReturn(null); replay(); ComponentSource source = new ComponentSourceImpl(null, null, globals); assertNull(source.getActivePage()); verify(); } }
@Override public void run() { componentSource.getPage(pageName); } }
@Test public void root_element_of_page() { RequestPageCache cache = mockRequestPageCache(); Page page = mockPage(); Component component = mockComponent(); ComponentClassResolver resolver = mockComponentClassResolver(); train_get(cache, PAGE_NAME, page); train_getRootComponent(page, component); replay(); ComponentSource source = new ComponentSourceImpl(cache, resolver, null); assertSame(source.getComponent(PAGE_NAME), component); verify(); }
@Test public void get_active_page() { RequestPageCache cache = mockRequestPageCache(); Page page = mockPage(); Component component = mockComponent(); ComponentClassResolver resolver = mockComponentClassResolver(); RequestGlobals globals = mockRequestGlobals(); String pageName = "Active"; expect(globals.getActivePageName()).andReturn(pageName); train_get(cache, pageName, page); train_getRootComponent(page, component); replay(); ComponentSource source = new ComponentSourceImpl(cache, resolver, globals); assertSame(source.getActivePage(), component); verify(); }
public Block getTabContent(String tabName) { Component page = componentSource.getPage(tab2PageName.get(tabName)); return page.getComponentResources().getBlock("content"); } }
@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 void processResultValue(Class value) throws IOException { String pageName = componentSource.getPage(value).getComponentResources().getPageName(); masterProcessor.processResultValue(pageName); } }
protected boolean redirectUnauthorizedUser(String pageName) throws IOException { Component page = componentSource.getPage(pageName);
private void trigger(String pageName, String eventType, Link link, Object parameters) { String pageClassName = resolver.resolvePageNameToClassName(pageName); ComponentModel model = modelSource.getModel(pageClassName); if (model.handlesEvent(eventType)) { Component page = componentSource.getPage(pageName); page.getComponentResources().triggerEvent(eventType, new Object[] { link, parameters }, null); } } }
@Override public void handle(ComponentEventRequestParameters parameters, ComponentEventRequestHandler handler) throws IOException { FileUploadException uploadException = decoder.getUploadException(); if (uploadException != null) { Component page = componentSource.getPage(parameters.getActivePageName()); ComponentResultProcessorWrapper callback = new ComponentResultProcessorWrapper(resultProcessor); page.getComponentResources().triggerEvent(UploadEvents.UPLOAD_EXCEPTION, new Object[] { uploadException }, callback); // If an event handler exists and returns a value, then the callback will be aborted and a response // (typically a redirect) will already have been sent to the client. if (callback.isAborted()) return; // If the page does not properly handle the exception, then we throw it now. throw new RuntimeException(UploadMessages.unableToDecode(), uploadException); } handler.handle(parameters); } }
@Override public void handle(ComponentEventRequestParameters parameters, ComponentEventRequestHandler handler) throws IOException { FileUploadException uploadException = decoder.getUploadException(); if (uploadException != null) { Component page = componentSource.getPage(parameters.getActivePageName()); ComponentResultProcessorWrapper callback = new ComponentResultProcessorWrapper(resultProcessor); page.getComponentResources().triggerEvent(UploadEvents.UPLOAD_EXCEPTION, new Object[] { uploadException }, callback); // If an event handler exists and returns a value, then the callback will be aborted and a response // (typically a redirect) will already have been sent to the client. if (callback.isAborted()) return; // If the page does not properly handle the exception, then we throw it now. throw new RuntimeException(UploadMessages.unableToDecode(), uploadException); } handler.handle(parameters); } }
@Test public void get_page_by_class() { RequestPageCache cache = mockRequestPageCache(); Page page = mockPage(); Component component = mockComponent(); ComponentClassResolver resolver = mockComponentClassResolver(); train_resolvePageClassNameToPageName(resolver, ComponentSourceImplTest.class.getName(), PAGE_NAME); train_get(cache, PAGE_NAME, page); train_getRootComponent(page, component); replay(); ComponentSource source = new ComponentSourceImpl(cache, resolver, null); assertSame(source.getPage(ComponentSourceImplTest.class), component); verify(); }
@Test public void get_page_by_logical_name() { RequestPageCache cache = mockRequestPageCache(); Page page = mockPage(); Component component = mockComponent(); ComponentClassResolver resolver = mockComponentClassResolver(); train_get(cache, PAGE_NAME, page); train_getRootComponent(page, component); replay(); ComponentSource source = new ComponentSourceImpl(cache, resolver, null); assertSame(source.getPage(PAGE_NAME), component); verify(); }