With jsf 1.1 you can do it this way:

  /**
   * Check whether this request is an AJAX Request
   * @return true if it is an AJAX Request; false otherwise
   */
  protected boolean isAjaxRequest()
  {
    ServletRequest request = (ServletRequest) 
FacesContext.getCurrentInstance().getExternalContext().getRequest();
    try
    {
      return null != 
request.getParameter(org.ajax4jsf.renderkit.AjaxContainerRenderer.AJAX_PARAMETER_NAME);
    }
    catch (Exception e)
    {
      // OCJ 10 - throw exception for static resources.
      return false;
    }
  }

-----Original Message-----
From: news [mailto:[email protected]] On Behalf Of Werner Punz
Sent: Mittwoch, 26. August 2009 10:27
To: [email protected]
Subject: Re: how to detect if a request is a ajax submit or normal submit?

Werner Punz schrieb:
> Dave schrieb:
>> We use jsf ri, tomahawk and ajax4jsf.
>>  
>> For a request, on server side how to detect whether the request is a
>> ajax submit or normal submit? Is there a HTTP header for this?  Thanks
>>  
> 
> In pre jsf 2.0 this is framework dependend, usually a request param is sent
> which marks the request as ajax request so that JSF can take over and do
> things differently for ajax.
> A unified marker for all this as well as some apis to check whether you
> are in an ajax cycle or not will be present in JSF 2.0 for now you have
> to check the framework documentation or the request itself which request
> parameter for the respective framework marks the request as an ajax one.
> (This is easy to do with the network monitor of firebug)
> 
Forgot to say in your case the a4j parameter is the one you have to look
for. A4j does the heavy lifting for you.

Werner


Reply via email to