Search in sources :

Example 1 with ViewHandler

use of javax.faces.application.ViewHandler 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);
}
Also used : ViewHandler(javax.faces.application.ViewHandler) Application(javax.faces.application.Application) UIViewRoot(javax.faces.component.UIViewRoot)

Example 2 with ViewHandler

use of javax.faces.application.ViewHandler 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);
}
Also used : FacesContext(javax.faces.context.FacesContext) ViewHandler(javax.faces.application.ViewHandler) Application(javax.faces.application.Application) UIViewRoot(javax.faces.component.UIViewRoot) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with ViewHandler

use of javax.faces.application.ViewHandler in project oxCore by GluuFederation.

the class FacesService method renderView.

public void renderView(String viewId) {
    final FacesContext fc = FacesContext.getCurrentInstance();
    final ViewHandler viewHandler = fc.getApplication().getViewHandler();
    fc.setViewRoot(viewHandler.createView(fc, viewId));
    fc.getPartialViewContext().setRenderAll(true);
    fc.renderResponse();
}
Also used : FacesContext(javax.faces.context.FacesContext) ViewHandler(javax.faces.application.ViewHandler)

Example 4 with ViewHandler

use of javax.faces.application.ViewHandler 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();
}
Also used : FacesContext(javax.faces.context.FacesContext) ViewHandler(javax.faces.application.ViewHandler) FacesContextFactory(javax.faces.context.FacesContextFactory) LifecycleFactory(javax.faces.lifecycle.LifecycleFactory) ServletContext(javax.servlet.ServletContext) Application(javax.faces.application.Application) UIViewRoot(javax.faces.component.UIViewRoot) PrintWriter(java.io.PrintWriter)

Example 5 with ViewHandler

use of javax.faces.application.ViewHandler in project opentheso by miledrousset.

the class SearchCandidatBean method refreshView.

public void refreshView() {
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = context.getViewRoot().getViewId();
    ViewHandler handler = context.getApplication().getViewHandler();
    UIViewRoot root = handler.createView(context, viewId);
    root.setViewId(viewId);
    context.setViewRoot(root);
}
Also used : PrimeFacesContext(org.primefaces.context.PrimeFacesContext) FacesContext(javax.faces.context.FacesContext) ViewHandler(javax.faces.application.ViewHandler) UIViewRoot(javax.faces.component.UIViewRoot)

Aggregations

ViewHandler (javax.faces.application.ViewHandler)8 UIViewRoot (javax.faces.component.UIViewRoot)7 FacesContext (javax.faces.context.FacesContext)5 Application (javax.faces.application.Application)3 PrintWriter (java.io.PrintWriter)1 FacesContextFactory (javax.faces.context.FacesContextFactory)1 LifecycleFactory (javax.faces.lifecycle.LifecycleFactory)1 PortletRequestDispatcher (javax.portlet.PortletRequestDispatcher)1 PortletSession (javax.portlet.PortletSession)1 ServletContext (javax.servlet.ServletContext)1 ErrorBean (org.alfresco.web.bean.ErrorBean)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 PrimeFacesContext (org.primefaces.context.PrimeFacesContext)1