Java Code Examples for javax.faces.context.FacesContext#isPostback()

The following examples show how to use javax.faces.context.FacesContext#isPostback() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DoubleSubmitAwarePhaseListener.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@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();
        }
    }
}
 
Example 2
Source File: ViewAccessScopedAwareNavigationHandler.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Override
public void handleNavigation(FacesContext context, String fromAction, String outcome)
{
    // remember viewId before navigation
    String viewId = null;
    if (context.getViewRoot() != null)
    {
        viewId = context.getViewRoot().getViewId();
    }

    this.navigationHandler.handleNavigation(context, fromAction, outcome);
    
    if (viewId != null && context.isPostback() /*need for supporting view-actions correctly - see DELTASPIKE-795*/)
    {
        lazyInit();

        ViewAccessContext viewAccessContext = contextExtension.getViewAccessScopedContext();
        if (viewAccessContext != null)
        {
            viewAccessContext.onProcessingViewFinished(viewId);
        }
    }
}
 
Example 3
Source File: AbstractClientWindowStrategy.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
protected boolean isPost(FacesContext facesContext)
{
    if (facesContext.isPostback())
    {
        return true;
    }

    Object request = facesContext.getExternalContext().getRequest();
    if (request instanceof HttpServletRequest)
    {
        if ("POST".equals(((HttpServletRequest) request).getMethod()))
        {
            return true;
        }
    }

    return false;
}