@Test public void getView_shouldGetAViewFromTheRequestedProvider() throws Exception { Assert.assertNotNull(factory.getView(null, pageRequest("somemodule", "somepage"))); try { factory.getView(null, pageRequest("somemodule", "otherpage")); Assert.fail("Expected exception"); } catch (UiFrameworkException ex) { } try { factory.getView(null, pageRequest("othermodule", "somepage")); Assert.fail("Expected exception"); } catch (UiFrameworkException ex) { } }
PageView getView(String viewProviderAndName, PageRequest request) { String providerName; String viewName; if (viewProviderAndName == null) { providerName = request.getMappedProviderName(); viewName = request.getMappedPageName(); } else { String[] temp = viewProviderAndName.split(":"); if (temp.length != 2) { throw new UiFrameworkException("Expected \"providerName:viewName\" but was \"" + viewProviderAndName + "\""); } providerName = temp[0]; viewName = temp[1]; } if ("*".equals(providerName)) { for (PageViewProvider p : viewProviders.values()) { PageView ret = p.getView(viewName); if (ret != null) { return ret; } } throw new UiFrameworkException("Could not find page view '" + viewName + "' in any of the view providers (" + OpenmrsUtil.join(viewProviders.keySet(), ", ") + ")"); } else { PageViewProvider provider = viewProviders.get(providerName); if (provider == null) { throw new UiFrameworkException("No viewProvider named " + providerName); } PageView ret = provider.getView(viewName); if (ret == null) { throw new UiFrameworkException("viewProvider " + providerName + " does not have a view named " + viewName); } return ret; } }
PageFactory { PageView getView(String viewProviderAndName, PageRequest request) { String providerName; String viewName; if (viewProviderAndName == null) { providerName = request.getMappedProviderName(); viewName = request.getMappedPageName(); } else { String[] temp = viewProviderAndName.split(":"); if (temp.length != 2) { throw new UiFrameworkException("Expected \"providerName:viewName\" but was \"" + viewProviderAndName + "\""); } providerName = temp[0]; viewName = temp[1]; } if ("*".equals(providerName)) { for (PageViewProvider p : viewProviders.values()) { PageView ret = p.getView(viewName); if (ret != null) { return ret; } } throw new UiFrameworkException("Could not find page view '" + viewName + "' in any of the view providers (" + OpenmrsUtil.join(viewProviders.keySet(), ", ") + ")"); } else { PageViewProvider provider = viewProviders.get(providerName); if (provider == null) { throw new UiFrameworkException("No viewProvider named " + providerName); } PageView ret = provider.getView(viewName); if (ret == null) { throw new UiFrameworkException("viewProvider " + providerName + " does not have a view named " + viewName); } return ret; } } }
PageFactory { PageView getView(String viewProviderAndName, PageRequest request) { String providerName; String viewName; if (viewProviderAndName == null) { providerName = request.getMappedProviderName(); viewName = request.getMappedPageName(); } else { String[] temp = viewProviderAndName.split(":"); if (temp.length != 2) { throw new UiFrameworkException("Expected \"providerName:viewName\" but was \"" + viewProviderAndName + "\""); } providerName = temp[0]; viewName = temp[1]; } if ("*".equals(providerName)) { for (PageViewProvider p : viewProviders.values()) { PageView ret = p.getView(viewName); if (ret != null) { return ret; } } throw new UiFrameworkException("Could not find page view '" + viewName + "' in any of the view providers (" + OpenmrsUtil.join(viewProviders.keySet(), ", ") + ")"); } else { PageViewProvider provider = viewProviders.get(providerName); if (provider == null) { throw new UiFrameworkException("No viewProvider named " + providerName); } PageView ret = provider.getView(viewName); if (ret == null) { throw new UiFrameworkException("viewProvider " + providerName + " does not have a view named " + viewName); } return ret; } }  }
PageFactory { PageView getView(String viewProviderAndName, PageRequest request) { String providerName; String viewName; if (viewProviderAndName == null) { providerName = request.getMappedProviderName(); viewName = request.getMappedPageName(); } else { String[] temp = viewProviderAndName.split(":"); if (temp.length != 2) { throw new UiFrameworkException("Expected \"providerName:viewName\" but was \"" + viewProviderAndName + "\""); } providerName = temp[0]; viewName = temp[1]; } if ("*".equals(providerName)) { for (PageViewProvider p : viewProviders.values()) { PageView ret = p.getView(viewName); if (ret != null) { return ret; } } throw new UiFrameworkException("Could not find page view '" + viewName + "' in any of the view providers (" + OpenmrsUtil.join(viewProviders.keySet(), ", ") + ")"); } else { PageViewProvider provider = viewProviders.get(providerName); if (provider == null) { throw new UiFrameworkException("No viewProvider named " + providerName); } PageView ret = provider.getView(viewName); if (ret == null) { throw new UiFrameworkException("viewProvider " + providerName + " does not have a view named " + viewName); } return ret; } }  String handle(PageRequest request); String process(PageContext context); Map<String, PageControllerProvider> getControllerProviders(); void setControllerProviders(Map<String, PageControllerProvider> newControllerProviders); void setAdditionalControllerProviders(Map<String, PageControllerProvider> additional); void addControllerProvider(String key, PageControllerProvider provider); Map<String, PageViewProvider> getViewProviders(); void setViewProviders(Map<String, PageViewProvider> newViewProviders); void setAdditionalViewProviders(Map<String, PageViewProvider> additional); void addViewProvider(String key, PageViewProvider provider); List<PageRequestMapper> getRequestMappers(); void setRequestMappers(List<PageRequestMapper> requestMappers); ConversionService getConversionService(); List<PageModelConfigurator> getModelConfigurators(); void setModelConfigurators(List<PageModelConfigurator> modelConfigurators); void setPossiblePageControllerArgumentProviders(List<PossiblePageControllerArgumentProvider> possiblePageControllerArgumentProviders); void setPageRequestInterceptors(List<PageRequestInterceptor> pageRequestInterceptors); }
PageFactory { PageView getView(String viewProviderAndName, PageRequest request) { String providerName; String viewName; if (viewProviderAndName == null) { providerName = request.getMappedProviderName(); viewName = request.getMappedPageName(); } else { String[] temp = viewProviderAndName.split(":"); if (temp.length != 2) { throw new UiFrameworkException("Expected \"providerName:viewName\" but was \"" + viewProviderAndName + "\""); } providerName = temp[0]; viewName = temp[1]; } if ("*".equals(providerName)) { for (PageViewProvider p : viewProviders.values()) { PageView ret = p.getView(viewName); if (ret != null) { return ret; } } throw new UiFrameworkException("Could not find page view '" + viewName + "' in any of the view providers (" + OpenmrsUtil.join(viewProviders.keySet(), ", ") + ")"); } else { PageViewProvider provider = viewProviders.get(providerName); if (provider == null) { throw new UiFrameworkException("No viewProvider named " + providerName); } PageView ret = provider.getView(viewName); if (ret == null) { throw new UiFrameworkException("viewProvider " + providerName + " does not have a view named " + viewName); } return ret; } }  String handle(PageRequest request); String process(PageContext context); Map<String, PageControllerProvider> getControllerProviders(); void setControllerProviders(Map<String, PageControllerProvider> newControllerProviders); void setAdditionalControllerProviders(Map<String, PageControllerProvider> additional); void addControllerProvider(String key, PageControllerProvider provider); Map<String, PageViewProvider> getViewProviders(); void setViewProviders(Map<String, PageViewProvider> newViewProviders); void setAdditionalViewProviders(Map<String, PageViewProvider> additional); void addViewProvider(String key, PageViewProvider provider); List<PageRequestMapper> getRequestMappers(); void setRequestMappers(List<PageRequestMapper> requestMappers); ConversionService getConversionService(); List<PageModelConfigurator> getModelConfigurators(); void setModelConfigurators(List<PageModelConfigurator> modelConfigurators); void setPossiblePageControllerArgumentProviders(List<PossiblePageControllerArgumentProvider> possiblePageControllerArgumentProviders); void setPageRequestInterceptors(List<PageRequestInterceptor> pageRequestInterceptors);  }