當前位置: 首頁>>代碼示例>>Java>>正文


Java PhaseEvent.getFacesContext方法代碼示例

本文整理匯總了Java中javax.faces.event.PhaseEvent.getFacesContext方法的典型用法代碼示例。如果您正苦於以下問題:Java PhaseEvent.getFacesContext方法的具體用法?Java PhaseEvent.getFacesContext怎麽用?Java PhaseEvent.getFacesContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.faces.event.PhaseEvent的用法示例。


在下文中一共展示了PhaseEvent.getFacesContext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: beforePhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
@Override
public void beforePhase(PhaseEvent phaseEvent) {
    FacesContext facesContext = phaseEvent.getFacesContext();
    HttpServletResponse response = (HttpServletResponse) facesContext
            .getExternalContext().getResponse();
    response.addHeader("Pragma", "no-cache");
    response.addHeader("Cache-Control", "no-cache,no-store,must-revalidate");
    response.addHeader("Expires", "0");

}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:11,代碼來源:NoCachePhaseListener.java

示例2: afterPhase

import javax.faces.event.PhaseEvent; //導入方法依賴的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

示例3: afterPhase

import javax.faces.event.PhaseEvent; //導入方法依賴的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

示例4: beforePhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
@Override
public void beforePhase(PhaseEvent pe) {
    FacesContext context = pe.getFacesContext();

    if (context.getAttributes().get(Constants.REQUEST_CONTEXT_ATTR) == null) {
        context.getAttributes().put(Constants.REQUEST_CONTEXT_ATTR, new DefaultRequestContext());
    }
}
 
開發者ID:websphere,項目名稱:SpringPrimeFacesShowcase,代碼行數:9,代碼來源:Primefaces35PhaseListener.java

示例5: processInitView

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
private void processInitView(PhaseEvent event)
{
    if (event.getPhaseId().equals(PhaseId.RESTORE_VIEW) && !isRedirectRequest(event.getFacesContext()))
    {
        return;
    }

    //TODO check if we have to restrict the other callbacks as well
    //leads to a call of @BeforePhase but not the corresponding @AfterPhase call of the corresponding callbacks

    //TODO don't call the callbacks in case of an initial redirct
    //was:
    /*
    if(Boolean.TRUE.equals(event.getFacesContext().getExternalContext().getRequestMap()
            .get(WindowContextManagerObserver.INITIAL_REDIRECT_PERFORMED_KEY)))
    {
        return;
    }
    */

    FacesContext facesContext = event.getFacesContext();
    if (facesContext.getViewRoot() != null && facesContext.getViewRoot().getViewId() != null)
    {
        processInitView(event.getFacesContext().getViewRoot().getViewId());
    }
}
 
開發者ID:apache,項目名稱:deltaspike,代碼行數:27,代碼來源:DeltaSpikePhaseListener.java

示例6: afterPhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
@Override
public void afterPhase(PhaseEvent event)
{
    FacesContext facesContext = event.getFacesContext();

    //only check full POST requests
    if (facesContext.isPostback() && !facesContext.getPartialViewContext().isAjaxRequest())
    {
        String receivedPostRequestToken = facesContext.getExternalContext()
            .getRequestParameterMap().get(PostRequestTokenMarker.POST_REQUEST_TOKEN_KEY);

        if (receivedPostRequestToken == null)
        {
            receivedPostRequestToken = findPostRequestTokenWithPrefix(facesContext);
        }

        if (!this.postRequestTokenManager.isValidRequest(receivedPostRequestToken))
        {
            facesContext.renderResponse();
        }
    }
}
 
開發者ID:apache,項目名稱:deltaspike,代碼行數:23,代碼來源:DoubleSubmitAwarePhaseListener.java

示例7: beforePhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
/**
 * Handle a notification that the processing for a particular phase of the
 * request processing lifecycle is about to begin.
 */
public void beforePhase(PhaseEvent event) {

	if(event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
		FacesContext facesContext = event.getFacesContext();
		restoreMessages(facesContext);
	}
}
 
開發者ID:hantsy,項目名稱:javaee8-jsf-sample,代碼行數:12,代碼來源:MessageHandler.java

示例8: afterPhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
/**
 * Handle a notification that the processing for a particular phase has just
 * been completed.
 */
public void afterPhase(PhaseEvent event) {

	if(event.getPhaseId() == PhaseId.APPLY_REQUEST_VALUES ||
			event.getPhaseId() == PhaseId.PROCESS_VALIDATIONS ||
			event.getPhaseId() == PhaseId.UPDATE_MODEL_VALUES || 
			event.getPhaseId() == PhaseId.INVOKE_APPLICATION) {

		FacesContext facesContext = event.getFacesContext();
		saveMessages(facesContext);
	}

}
 
開發者ID:hantsy,項目名稱:javaee8-jsf-sample,代碼行數:17,代碼來源:MessageHandler.java

示例9: afterPhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
@Override
public void afterPhase(PhaseEvent arg0) {
	FacesContext facesContext = arg0.getFacesContext();
	UIViewRoot uiViewRoot = facesContext.getViewRoot();
	if (getCancelButton(uiViewRoot) != null)
		facesContext.getViewRoot().setViewId(oldViewId);
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:8,代碼來源:BackButton.java

示例10: beforePhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
@Override
public void beforePhase(PhaseEvent arg0) {
	FacesContext facesContext = arg0.getFacesContext();
	UIViewRoot uiViewRoot = facesContext.getViewRoot();
	if (getCancelButton(uiViewRoot) == null)
		oldViewId = uiViewRoot.getViewId();
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:8,代碼來源:BackButton.java

示例11: beforePhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
/**
 * in RENDER_RESPONSE restore facesMessages
 */
public void beforePhase(PhaseEvent event) {
    if (event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
        FacesContext facesContext = event.getFacesContext();
        restoreMessages(facesContext);
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:10,代碼來源:MessageHandler.java

示例12: afterPhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
/**
 * save messages after APPLY_REQUEST_VALUES, PROCESS_VALIDATIONS,
 * INVOKE_APPLICATION
 */
public void afterPhase(PhaseEvent event) {
    if (event.getPhaseId() == PhaseId.APPLY_REQUEST_VALUES
            || event.getPhaseId() == PhaseId.PROCESS_VALIDATIONS
            || event.getPhaseId() == PhaseId.INVOKE_APPLICATION) {
        FacesContext facesContext = event.getFacesContext();
        saveMessages(facesContext);
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:13,代碼來源:MessageHandler.java

示例13: afterPhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void afterPhase(PhaseEvent event)
{
  FacesContext context = event.getFacesContext();

  if (event.getPhaseId() == PhaseId.RESTORE_VIEW)
  {
    // Store off the current ViewRoot so we can check for a full page
    // render in response to a partial event.
    context.getExternalContext().getRequestMap().put(INITIAL_VIEW_ROOT_KEY,
                                                     context.getViewRoot());
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:14,代碼來源:TrinidadPhaseListener.java

示例14: afterPhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
@Override
public void afterPhase(PhaseEvent event) 
{
    FacesContext facesContext = event.getFacesContext();// saber em que pagina se encontra
    UIViewRoot uiViewRoot = facesContext.getViewRoot();// devolve a página atual
    String paginaAtual = uiViewRoot.getViewId();
    boolean paginaAutenticacao = paginaAtual.contains("index.xhtml");
    boolean paginaAcessoNegado = paginaAtual.contains("denied.xhtml");
    boolean paginaNoPagina = paginaAtual.contains("error-404.xhtml");
    boolean paginaNovoSeguroApolice = paginaAtual.contains("GestSeg_NovoSeguroApolice.xhtml");
    boolean paginaNovoSeguro = paginaAtual.contains("GestSeg_NovoSeguro.xhtml");
    boolean paginaSegContrato = paginaAtual.contains("GestSeg_Contratos.xhtml");
    
    if(SessionUtil.obterValor(Funcionario.SESSION_NAME) != null)
    {
        if(SessionUtil.getUserlogado().getNivelAcesso().equals("3") || SessionUtil.getUserlogado().getIdDepartamento().equals("5"))
            RequestContext.getCurrentInstance().execute("menuAnalista('"+SessionUtil.getUserlogado().getIdDepartamento()+"')");
        else if(SessionUtil.getUserlogado().getNivelAcesso().equals("2") || SessionUtil.getUserlogado().getNivelAcesso().equals("5") )
            RequestContext.getCurrentInstance().execute("admOperario()");
        else
            RequestContext.getCurrentInstance().execute("passado()");
    }
    
    if(!paginaSegContrato){ MarcaDAgua.isCanceled = false; }
   
   if(!paginaAutenticacao && SessionUtil.obterValor(Funcionario.SESSION_NAME) == null) 
        Validacao.redirecionar("../index.xhtml");
   if(!paginaNovoSeguro&&!paginaNovoSeguroApolice)
       sharchSessaoRemove();
}
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:31,代碼來源:AutenticacaoPhaseListener.java

示例15: beforePhase

import javax.faces.event.PhaseEvent; //導入方法依賴的package包/類
public void beforePhase(PhaseEvent event) {
    FacesHelper helper = new FacesHelper(event.getFacesContext());
    if (event.getPhaseId().equals(PhaseId.RESTORE_VIEW)) {
        log.debug("before phase: RESTORE_VIEW");
        setup(helper);
    } else if (event.getPhaseId().equals(PhaseId.APPLY_REQUEST_VALUES)) {
        log.debug("before phase: APPLY_REQUEST_VALUES");
        processPopulateFlashValues(helper);
        processPageSetUp(helper);

    } else if (event.getPhaseId().equals(PhaseId.RENDER_RESPONSE)) {
        log.debug("before phase: RENDER_RESPONSE");
        process(helper);
    }
}
 
開發者ID:otsecbsol,項目名稱:linkbinder,代碼行數:16,代碼來源:ExtendedPhaseListener.java


注:本文中的javax.faces.event.PhaseEvent.getFacesContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。