use of javax.faces.component.UIViewRoot in project ART-TIME by Artezio.
the class EffortsBean method resetComponentsTree.
protected void resetComponentsTree() {
Application application = facesContext.getApplication();
ViewHandler viewHandler = application.getViewHandler();
UIViewRoot viewRoot = viewHandler.createView(facesContext, facesContext.getViewRoot().getViewId());
facesContext.setViewRoot(viewRoot);
}
use of javax.faces.component.UIViewRoot in project ART-TIME by Artezio.
the class ExceptionHandlerTest method setUp.
@Before
public void setUp() throws Exception {
FacesContextMocker.mockFacesContext();
ExternalContext externalContext = mock(ExternalContext.class);
when(FacesContext.getCurrentInstance().getExternalContext()).thenReturn(externalContext);
servletContext = mock(ServletContext.class);
when(FacesContext.getCurrentInstance().getExternalContext().getContext()).thenReturn(servletContext);
InputStream input = new FileInputStream(ERROR_MESSAGES_PROPERTIES_PATH);
when(servletContext.getResourceAsStream(anyString())).thenReturn(input);
UIViewRoot viewRoot = mock(UIViewRoot.class);
when(FacesContext.getCurrentInstance().getViewRoot()).thenReturn(viewRoot);
when(viewRoot.getChildren()).thenReturn(new ArrayList<>());
wrappedExceptionHandler = mock(javax.faces.context.ExceptionHandler.class);
}
use of javax.faces.component.UIViewRoot in project ART-TIME by Artezio.
the class EffortsBeanTest method testResetComponentsTree.
@Test
public void testResetComponentsTree() throws Exception {
FacesContext facesContext = createMock(FacesContext.class);
Application application = createMock(Application.class);
ViewHandler viewHandler = createMock(ViewHandler.class);
UIViewRoot viewRoot = createMock(UIViewRoot.class);
String viewId = "viewId";
setField(effortsBean, "facesContext", facesContext);
expect(facesContext.getApplication()).andReturn(application);
expect(application.getViewHandler()).andReturn(viewHandler);
expect(facesContext.getViewRoot()).andReturn(viewRoot);
expect(viewRoot.getViewId()).andReturn(viewId);
expect(viewHandler.createView(facesContext, viewId)).andReturn(viewRoot);
facesContext.setViewRoot(viewRoot);
replay(facesContext, application, viewHandler, viewRoot);
effortsBean.resetComponentsTree();
verify(facesContext, application, viewHandler, viewRoot);
}
use of javax.faces.component.UIViewRoot in project ART-TIME by Artezio.
the class WebCachedInterceptorTest method testGetContextProperties_forViewScope.
@Test
public void testGetContextProperties_forViewScope() {
Map<String, Object> contextProperties = new HashMap<String, Object>();
UIViewRoot viewRoot = createMock(UIViewRoot.class);
expect(facesContextMock.getViewRoot()).andReturn(viewRoot);
expect(viewRoot.getViewMap()).andReturn(contextProperties);
replay(facesContextMock, viewRoot);
Map<String, Object> actual = interceptor.getContextProperties(Scope.VIEW_SCOPED);
verify(facesContextMock, viewRoot);
assertEquals(contextProperties, actual);
}
use of javax.faces.component.UIViewRoot in project Payara by payara.
the class JSFTestServlet method doGet.
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
ServletContext context = getServletContext();
FacesContext facesContext = facesContextFactory.getFacesContext(context, request, response, lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE));
Application application = facesContext.getApplication();
ViewHandler viewHandler = application.getViewHandler();
UIViewRoot viewRoot = viewHandler.createView(facesContext, null);
facesContext.setViewRoot(viewRoot);
PrintWriter pw = response.getWriter();
pw.println("Created viewRoot " + viewRoot);
pw.flush();
pw.close();
}
Aggregations