当前位置: 首页>>代码示例>>Java>>正文


Java NavigationHandler类代码示例

本文整理汇总了Java中javax.faces.application.NavigationHandler的典型用法代码示例。如果您正苦于以下问题:Java NavigationHandler类的具体用法?Java NavigationHandler怎么用?Java NavigationHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NavigationHandler类属于javax.faces.application包,在下文中一共展示了NavigationHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logout

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
public void logout() {
        FacesContext fc = javax.faces.context.FacesContext.getCurrentInstance();
        ((HttpSession) fc.getExternalContext().getSession(false)).invalidate();
//        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().clear();        
        Application ap = fc.getApplication();
        NavigationHandler nh = ap.getNavigationHandler();
        //Generate Logout Dialog
        List<String> buttonTextList = new ArrayList<String>();
        buttonTextList.add(resolve("Login", new Object[]{}));
        NotifyDescriptorExt n = new NotifyDescriptorExt(Constants.INFORMATION_ICON, resolve("Logouted", new Object[]{}), resolve("LogoutMessage", new Object[]{}), buttonTextList);
        String page = n.setCallbackListener(new ButtonListener() {

            public String buttonClicked(final int buttonId, NotifyDescriptorExtBean notifyDescriptorBean) {
                return NavigationEnum.controller_CenterPanel.toString();
            }
        });
        //Load the NotifyDescriptor because after logout the JSF logic is expired.
        nh.handleNavigation(fc, null, page);
    }
 
开发者ID:salimvanak,项目名称:myWMS,代码行数:20,代码来源:JSFHelper.java

示例2: handle

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    
    for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
        Throwable t = context.getException();
        if (t instanceof ViewExpiredException) {
            FacesContext fc = FacesContext.getCurrentInstance();
            NavigationHandler nav = fc.getApplication().getNavigationHandler();
            try {
                nav.handleNavigation(fc, null, "expired?faces-redirect=true&amp;includeViewParams=true");
                fc.renderResponse();
            } finally {
                i.remove();
            }
        }
    }
    // At this point, the queue will not contain any ViewExpiredEvents.
    // Therefore, let the parent handle them.
    getWrapped().handle();

}
 
开发者ID:drifted-in,项目名称:genopro-tools,代码行数:24,代码来源:ViewExpiredExceptionExceptionHandler.java

示例3: processAction

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
public void processAction(ActionEvent actionEvent) {
    FacesContext context = FacesContext.getCurrentInstance();
    UINamingContainer loginComponent
        = (UINamingContainer)context.getAttributes().get(UIComponent.CURRENT_COMPOSITE_COMPONENT);
    MethodExpression loginAction = (MethodExpression)loginComponent.getAttributes().get("cancelAction");
    try {
        loginAction.invoke(context.getELContext(), new Object[] {});
    } catch (Exception e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Login-cancellation could not be fulfilled.", e);
        } else {
            LOG.info("Login-cancellation could not be fulfilled: " + e.getMessage());
        }
    }
    NavigationHandler navigationHandler = context.getApplication().getNavigationHandler();
    String outcome = (String)context.getExternalContext().getRequestParameterMap().get("outcome");
    if (outcome != null) {
        navigationHandler.handleNavigation(context, null, outcome);
    }
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:21,代码来源:CancelActionListener.java

示例4: processAction

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
public void processAction(ActionEvent actionEvent) {
    FacesContext context = FacesContext.getCurrentInstance();
    UINamingContainer loginComponent
        = (UINamingContainer)context.getAttributes().get(UIComponent.CURRENT_COMPOSITE_COMPONENT);
    UIInput username = (UIInput)loginComponent.findComponent("loginDialog:loginForm:username");
    UIInput password = (UIInput)loginComponent.findComponent("loginDialog:loginForm:password");
    MethodExpression loginAction = (MethodExpression)loginComponent.getAttributes().get("loginAction");
    try {
        loginAction.invoke(context.getELContext(), new Object[] {username.getValue(), password.getValue()});
        NavigationHandler navigationHandler = context.getApplication().getNavigationHandler();
        String outcome = (String)context.getExternalContext().getRequestParameterMap().get("outcome");
        if (outcome != null) {
            navigationHandler.handleNavigation(context, null, outcome);
        }
    } catch (Exception e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Login could not be established.", e);
        } else {
            LOG.info("Login could not be established: " + e.getMessage());
        }
    }
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:23,代码来源:LoginActionListener.java

示例5: handle

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();

        Throwable t = context.getException();
        if (t instanceof ViewExpiredException) {
            ViewExpiredException vee = (ViewExpiredException) t;
            FacesContext facesContext = FacesContext.getCurrentInstance();
            Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
            NavigationHandler navigationHandler = facesContext.getApplication().getNavigationHandler();
            try {
                // Push some useful stuff to the request scope for use in the page
                requestMap.put("currentViewId", vee.getViewId());
                navigationHandler.handleNavigation(facesContext, null, "/viewExpired");
                facesContext.renderResponse();
            } finally {
                i.remove();
            }
        }
    }

    // At this point, the queue will not contain any ViewExpiredEvents. Therefore, let the parent handle them.
    getWrapped().handle();
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:27,代码来源:ViewExpiredExceptionExceptionHandler-template.java

示例6: afterPhase

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
public void afterPhase(PhaseEvent event) {
	FacesContext facesContext = event.getFacesContext();
	String currentPage = facesContext.getViewRoot().getViewId();
	boolean isLoginPage = (currentPage.lastIndexOf("login.jsp") > -1);
	
	HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
	
	String user = (String)session.getAttribute("userName");

	if (!isLoginPage && user == null) {
		NavigationHandler nh = facesContext.getApplication()
				.getNavigationHandler();
		nh.handleNavigation(facesContext, null, "loginPage");
	}

}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:17,代码来源:AuthorizationListener.java

示例7: gotoPage

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
/**
 * redirects to the specified page
 * @param page the name of the page to go to
 */
public void gotoPage(String page) {
    Application app = getApplication() ;
    if (app != null) {
        NavigationHandler navigator = app.getNavigationHandler();
        navigator.handleNavigation(getFacesContext(), null, page);
    }

    // if app is null, session has been destroyed
    else {
        try {
            FacesContext.getCurrentInstance().getExternalContext().redirect("Login.jsp");
        }
        catch (IOException ioe) {
            // message about destroyed app
        }
    }
}
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:22,代码来源:SessionBean.java

示例8: gotoPage

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
/**
 * redirects to the specified page
 * @param page the name of the page to go to
 */
public void gotoPage(String page) {
    Application app = getApplication() ;
    if (app != null) {
        NavigationHandler navigator = app.getNavigationHandler();
        navigator.handleNavigation(getFacesContext(), null, page);
    }

    // if app is null, session has been destroyed
    else {
        try {
            FacesContext.getCurrentInstance().getExternalContext().redirect("msLogin.jsp");
        }
        catch (IOException ioe) {
            // message about destroyed app
        }
    }
}
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:22,代码来源:SessionBean.java

示例9: handle

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
/**
 * Method for handling done-editing action(e.g. "done_editing_doc")
 * @param event Action Event
 */
public void handle(ActionEvent event)
{
   setupContentAction(event);

   FacesContext fc = FacesContext.getCurrentInstance();
   NavigationHandler nh = fc.getApplication().getNavigationHandler();
   // if content is versionable then check-in else move to dialog for filling version info
   if (isVersionable())
   {
      nh.handleNavigation(fc, null, DIALOG_NAME);
   }
   else
   {
      checkinFileOK(fc, null);
      nh.handleNavigation(fc, null, AlfrescoNavigationHandler.DIALOG_PREFIX + "browse");
   }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:22,代码来源:DoneEditingDialog.java

示例10: afterPhase

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
@Override
public void afterPhase(PhaseEvent event) {    	
	// Obtém o contexto atual
    FacesContext contexto = event.getFacesContext();
    
    // Obter o caminho do contexto
    String caminho = contexto.getExternalContext().getRequestServletPath();
    
    try {
    	// Verifica se o caminho contém o diretório 'admin'
    	if (caminho.indexOf("admin") > -1 && !(caminho.indexOf("menu") > -1)) {
    		security.isAutheticated(security.getUsername());
    	}
    } catch (BusinessException be) {
    	// Em caso de exceção redireciona para a página de login
    	NavigationHandler nh = contexto.getApplication().getNavigationHandler();
        nh.handleNavigation(contexto, null, "logoutSucesso");
    }
}
 
开发者ID:herculeshssj,项目名称:imobiliariaweb,代码行数:20,代码来源:SessaoListener.java

示例11: handleExceptionMsgPage

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
/**
 * Handle an exception with just redirects to an error page with a message
 * 
 * @param i
 *            iterator to remove from on success
 * @param facelet
 *            JSF view to redirect to
 * @param msg
 *            message to display
 */
private void handleExceptionMsgPage( FacesContext fc, Iterator<ExceptionQueuedEvent> i, String facelet, String msg ) {

	NavigationHandler nav = fc.getApplication().getNavigationHandler();
	try {
		final String msgKey = RandomPassword.getPassword( 10 );
		Object sessionObj = fc.getExternalContext().getSession( true );
		if ( sessionObj instanceof HttpSession ) {
			((HttpSession) sessionObj).setAttribute( msgKey, msg );
		}

		nav.handleNavigation( fc, null, facelet + "?msgKey=" + msgKey + "&faces-redirect=true" );
		fc.renderResponse();
	}
	catch ( Exception eee ) {
	}
	finally {
		if ( i != null ) {
			i.remove();
		}
	}
}
 
开发者ID:PE-INTERNATIONAL,项目名称:soda4lca,代码行数:32,代码来源:FacesExceptionHandler.java

示例12: handle

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    Iterable<ExceptionQueuedEvent> events = this.wrapped.getUnhandledExceptionQueuedEvents();
    for(Iterator<ExceptionQueuedEvent> it = events.iterator(); it.hasNext();) {
        ExceptionQueuedEvent event = it.next();
        ExceptionQueuedEventContext eqec = event.getContext();
        
        if(eqec.getException() instanceof ViewExpiredException) {
            FacesContext context = eqec.getContext();
            if(!context.isReleased()) {
                NavigationHandler navHandler = context.getApplication().getNavigationHandler();
 
                try {
                    navHandler.handleNavigation(context, null, "home?faces-redirect=true&expired=true");
                }
                finally {
                    it.remove();
                }
            }
            
        }
    }

    this.wrapped.handle();
}
 
开发者ID:websphere,项目名称:PrimefacesShowcase,代码行数:26,代码来源:ShowcaseExceptionHandler.java

示例13: wrapNavigationHandler

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
private NavigationHandler wrapNavigationHandler(NavigationHandler handler)
{
    NavigationHandler result = null;

    if (manualNavigationHandlerWrapperMode == null)
    {
        lazyInit();
    }

    //jsf 2.2+
    if (!manualNavigationHandlerWrapperMode)
    {
        result = wrapNavigationHandlerWithNewWrapper(handler);
    }
    if (result != null)
    {
        return result;
    }

    //jsf 2.0 and 2.1
    return new DeltaSpikeNavigationHandler(handler);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:23,代码来源:NavigationHandlerAwareApplication.java

示例14: wrapNavigationHandlerWithNewWrapper

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
private NavigationHandler wrapNavigationHandlerWithNewWrapper(NavigationHandler handler)
{
    if (ConfigurableNavigationHandler.class.isAssignableFrom(handler.getClass()))
    {
        try
        {
            Constructor deltaSpikeNavigationHandlerWrapperConstructor =
                this.navigationHandlerWrapperClass.getConstructor(ConfigurableNavigationHandler.class);

            NavigationHandler navigationHandlerWrapper =
                (NavigationHandler)deltaSpikeNavigationHandlerWrapperConstructor.newInstance(handler);
            return  navigationHandlerWrapper;
        }
        catch (Exception e)
        {
            throw ExceptionUtils.throwAsRuntimeException(e);
        }
    }

    return null;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:22,代码来源:NavigationHandlerAwareApplication.java

示例15: handle

import javax.faces.application.NavigationHandler; //导入依赖的package包/类
@Override
public void handle() throws FacesException {
    Iterable<ExceptionQueuedEvent> events = this.wrapped.getUnhandledExceptionQueuedEvents();
    for(Iterator<ExceptionQueuedEvent> it = events.iterator(); it.hasNext();) {
        ExceptionQueuedEvent event = it.next();
        ExceptionQueuedEventContext eqec = event.getContext();
        System.out.println("eqec.getException()"+eqec.getException());
        if(eqec.getException() instanceof ViewExpiredException || eqec.getException() instanceof AbortProcessingException) {
            FacesContext context = eqec.getContext();
            NavigationHandler navHandler = context.getApplication().getNavigationHandler();
 
            try {
                navHandler.handleNavigation(context, null, "main.xhtml?faces-redirect=true&expired=true");
            }
            catch(Exception e){
                System.out.println("exp"+e);
            }
            finally {
                it.remove();
            }
        }
    }

    this.wrapped.handle();;
}
 
开发者ID:wbstr,项目名称:liferay-newsletter,代码行数:26,代码来源:WcsExceptionHandler.java


注:本文中的javax.faces.application.NavigationHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。