Search in sources :

Example 11 with NavigationHandler

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

the class EditSpaceCommand method execute.

/**
 * @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
 */
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties) {
    ServletContext sc = (ServletContext) properties.get(PROP_SERVLETCONTEXT);
    ServletRequest req = (ServletRequest) properties.get(PROP_REQUEST);
    ServletResponse res = (ServletResponse) properties.get(PROP_RESPONSE);
    FacesContext fc = FacesHelper.getFacesContext(req, res, sc, "/jsp/close.jsp");
    BrowseBean browseBean = (BrowseBean) FacesHelper.getManagedBean(fc, BrowseBean.BEAN_NAME);
    // setup context from url args in properties map
    String strNodeRef = (String) properties.get(PROP_NODEREF);
    ParameterCheck.mandatoryString(PROP_NODEREF, strNodeRef);
    browseBean.setActionSpace(new Node(new NodeRef(strNodeRef)));
    NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
    navigationHandler.handleNavigation(fc, null, "dialog:editSpace");
    String viewId = fc.getViewRoot().getViewId();
    try {
        sc.getRequestDispatcher(BaseServlet.FACES_SERVLET + viewId).forward(req, res);
    } catch (Exception e) {
        throw new AlfrescoRuntimeException("Unable to forward to viewId: " + viewId, e);
    }
    return null;
}
Also used : ServletRequest(javax.servlet.ServletRequest) ServletResponse(javax.servlet.ServletResponse) FacesContext(javax.faces.context.FacesContext) NodeRef(org.alfresco.service.cmr.repository.NodeRef) BrowseBean(org.alfresco.web.bean.BrowseBean) Node(org.alfresco.web.bean.repository.Node) ServletContext(javax.servlet.ServletContext) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) NavigationHandler(javax.faces.application.NavigationHandler) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 12 with NavigationHandler

use of javax.faces.application.NavigationHandler in project core by weld.

the class Crossroad method goingWithGuide.

public void goingWithGuide() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    NavigationHandler navHandler = facesContext.getApplication().getNavigationHandler();
    navHandler.handleNavigation(facesContext, null, "/road.jsf");
}
Also used : FacesContext(javax.faces.context.FacesContext) NavigationHandler(javax.faces.application.NavigationHandler)

Example 13 with NavigationHandler

use of javax.faces.application.NavigationHandler in project fit3d by fkaiserbio.

the class Fit3DExceptionHandler method handle.

@Override
public void handle() throws FacesException {
    final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();
    while (i.hasNext()) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
        // get the exception from context
        Throwable t = context.getException();
        final FacesContext fc = FacesContext.getCurrentInstance();
        final Map<String, Object> requestMap = fc.getExternalContext().getRequestMap();
        final NavigationHandler nav = fc.getApplication().getNavigationHandler();
        // here you do what ever you want with exception
        try {
            // log error ?
            logger.error(t.getMessage(), t);
            Flash flash = fc.getExternalContext().getFlash();
            // Put the exception in the flash scope to be displayed in the
            // error
            // page if necessary ...
            // TODO prevent direct access to errorpage
            flash.put("errorDetails", t.getMessage());
            // redirect error page
            requestMap.put("exceptionMessage", t.getMessage());
            nav.handleNavigation(fc, null, "/errorpages/generic");
            fc.renderResponse();
        // remove the comment below if you want to report the error in a
        // jsf error message
        // JsfUtil.addErrorMessage(t.getMessage());
        } finally {
            // remove it from queue
            i.remove();
        }
    }
    // parent handle
    getWrapped().handle();
}
Also used : ExceptionQueuedEvent(javax.faces.event.ExceptionQueuedEvent) FacesContext(javax.faces.context.FacesContext) ExceptionQueuedEventContext(javax.faces.event.ExceptionQueuedEventContext) NavigationHandler(javax.faces.application.NavigationHandler) Flash(javax.faces.context.Flash)

Aggregations

NavigationHandler (javax.faces.application.NavigationHandler)13 FacesContext (javax.faces.context.FacesContext)11 ServletContext (javax.servlet.ServletContext)4 ServletRequest (javax.servlet.ServletRequest)4 ServletResponse (javax.servlet.ServletResponse)4 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)4 NodeRef (org.alfresco.service.cmr.repository.NodeRef)3 BrowseBean (org.alfresco.web.bean.BrowseBean)3 AlfrescoNavigationHandler (org.alfresco.web.app.AlfrescoNavigationHandler)2 Node (org.alfresco.web.bean.repository.Node)2 Constructor (java.lang.reflect.Constructor)1 Stack (java.util.Stack)1 StringTokenizer (java.util.StringTokenizer)1 ConfigurableNavigationHandler (javax.faces.application.ConfigurableNavigationHandler)1 Flash (javax.faces.context.Flash)1 ExceptionQueuedEvent (javax.faces.event.ExceptionQueuedEvent)1 ExceptionQueuedEventContext (javax.faces.event.ExceptionQueuedEventContext)1 ServiceRegistry (org.alfresco.service.ServiceRegistry)1 StoreRef (org.alfresco.service.cmr.repository.StoreRef)1 PermissionService (org.alfresco.service.cmr.security.PermissionService)1