本文整理匯總了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");
}
示例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");
}
}
示例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");
}
}
示例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());
}
}
示例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());
}
}
示例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();
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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());
}
}
示例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();
}
示例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);
}
}