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);
}
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);
}
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();
}
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);
}
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();
}
Aggregations