Search in sources :

Example 6 with ViewHandler

use of javax.faces.application.ViewHandler in project acs-community-packaging by Alfresco.

the class BaseActionWizard method goToPage.

/**
 * Navigates to the given page, used to go back and forth between the
 * wizard and the actions settings pages
 *
 * @param context FacesContext
 * @param viewId The viewId to go to
 */
protected void goToPage(FacesContext context, String viewId) {
    ViewHandler viewHandler = context.getApplication().getViewHandler();
    UIViewRoot viewRoot = viewHandler.createView(context, viewId);
    viewRoot.setViewId(viewId);
    context.setViewRoot(viewRoot);
    context.renderResponse();
}
Also used : ViewHandler(javax.faces.application.ViewHandler) UIViewRoot(javax.faces.component.UIViewRoot)

Example 7 with ViewHandler

use of javax.faces.application.ViewHandler in project acs-community-packaging by Alfresco.

the class AlfrescoFacesPortlet method handleError.

/**
 * Handles errors that occur during a render request
 */
private void handleError(RenderRequest request, RenderResponse response, Throwable error) throws PortletException, IOException {
    // get the error bean from the session and set the error that occurred.
    PortletSession session = request.getPortletSession();
    ErrorBean errorBean = (ErrorBean) session.getAttribute(ErrorBean.ERROR_BEAN_NAME, PortletSession.PORTLET_SCOPE);
    if (errorBean == null) {
        errorBean = new ErrorBean();
        session.setAttribute(ErrorBean.ERROR_BEAN_NAME, errorBean, PortletSession.PORTLET_SCOPE);
    }
    errorBean.setLastError(error);
    // if the faces context is available set the current view to the browse page
    // so that the error page goes back to the application (rather than going back
    // to the same page which just throws the error again meaning we can never leave
    // the error page)
    FacesContext context = FacesContext.getCurrentInstance();
    if (context != null) {
        ViewHandler viewHandler = context.getApplication().getViewHandler();
        // TODO: configure the portlet error return page
        UIViewRoot view = viewHandler.createView(context, FacesHelper.BROWSE_VIEW_ID);
        context.setViewRoot(view);
    }
    // get the error page and include that instead
    String errorPage = getErrorPage();
    if (logger.isDebugEnabled())
        logger.debug("An error has occurred, redirecting to error page: " + errorPage);
    response.setContentType("text/html");
    PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(errorPage);
    dispatcher.include(request, response);
}
Also used : PortletRequestDispatcher(javax.portlet.PortletRequestDispatcher) FacesContext(javax.faces.context.FacesContext) PortletSession(javax.portlet.PortletSession) ErrorBean(org.alfresco.web.bean.ErrorBean) ViewHandler(javax.faces.application.ViewHandler) UIViewRoot(javax.faces.component.UIViewRoot)

Example 8 with ViewHandler

use of javax.faces.application.ViewHandler in project acs-community-packaging by Alfresco.

the class AlfrescoNavigationHandler method goToView.

/**
 * Dispatches to the given view id
 *
 * @param context Faces context
 * @param viewId The view id to go to
 */
private void goToView(FacesContext context, String viewId) {
    ViewHandler viewHandler = context.getApplication().getViewHandler();
    UIViewRoot viewRoot = viewHandler.createView(context, viewId);
    viewRoot.setViewId(viewId);
    context.setViewRoot(viewRoot);
    context.renderResponse();
}
Also used : 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