Search in sources :

Example 6 with UIViewRoot

use of javax.faces.component.UIViewRoot 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)

Example 7 with UIViewRoot

use of javax.faces.component.UIViewRoot in project Payara by payara.

the class UtilHandlers method createDefaultViewRoot.

/**
 *	<p> This method returns a new UIViewRoot with the basic JSFT settings
 *	    from the current ViewRoot.  If you intend to set this before the
 *	    current view is created (in an effort to swap out the UIViewRoot),
 *	    you should do so during the initPage event (take care to only do
 *	    this during the first request, or you might lose all child
 *	    components).</p>
 * @param handlerCtx
 */
@Handler(id = "createDefaultViewRoot", output = { @HandlerOutput(name = "viewRoot", type = UIViewRoot.class) })
public static void createDefaultViewRoot(HandlerContext handlerCtx) {
    UIViewRoot oldVR = handlerCtx.getFacesContext().getViewRoot();
    UIViewRoot newVR = new UIViewRoot();
    newVR.setViewId(oldVR.getViewId());
    ViewRootUtil.setLayoutDefinitionKey(newVR, ViewRootUtil.getLayoutDefinitionKey(oldVR));
    newVR.setLocale(oldVR.getLocale());
    newVR.setRenderKitId(oldVR.getRenderKitId());
    handlerCtx.setOutputValue("viewRoot", newVR);
}
Also used : UIViewRoot(javax.faces.component.UIViewRoot) Handler(com.sun.jsftemplating.annotation.Handler)

Example 8 with UIViewRoot

use of javax.faces.component.UIViewRoot 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 9 with UIViewRoot

use of javax.faces.component.UIViewRoot 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 10 with UIViewRoot

use of javax.faces.component.UIViewRoot 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

UIViewRoot (javax.faces.component.UIViewRoot)41 FacesContext (javax.faces.context.FacesContext)18 Test (org.junit.Test)10 ViewHandler (javax.faces.application.ViewHandler)8 Locale (java.util.Locale)6 ResourceBundle (java.util.ResourceBundle)4 Application (javax.faces.application.Application)3 UIComponent (javax.faces.component.UIComponent)3 ViewConfigDescriptor (org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Map (java.util.Map)2 ExternalContext (javax.faces.context.ExternalContext)2 FacesContextFactory (javax.faces.context.FacesContextFactory)2 PreDestroyViewMapEvent (javax.faces.event.PreDestroyViewMapEvent)2 LifecycleFactory (javax.faces.lifecycle.LifecycleFactory)2 ServletContext (javax.servlet.ServletContext)2 NonNull (org.springframework.lang.NonNull)2 Handler (com.sun.jsftemplating.annotation.Handler)1 ModuleException (it.vige.rubia.ModuleException)1 ToHTMLConfig (it.vige.rubia.format.render.bbcodehtml.ToHTMLConfig)1