Well my interceptor was working already with the request object so from there
I just got the request URL. All my AJAX operations have the word Ajax in
them. So I just check if there's an Ajax string in my request URL.

This is what I had in my code:

boolean ajaxOperation = request.getRequestURL().indexOf("Ajax") > -1;

Although I don't know if that's the best approach since I'm fairly new to
this as well. Hope that helps!


Pablo Vazquez wrote:
> 
> - the interceptor can detect that the request is ajax either by the 
> partitioning of your packages/URLs or by inspecting the http header;
> 
> How can you know it is an ajax request by inspecting the http header?
> I looked in my request headers and I can´t know whether it is ajax or not.
> 
> Thanks.
> 
> Jeromy Evans escribió:
>> Grish wrote:
>>> Is there a way to intercept these ajax actions and properly direct my 
>>> users
>>> to the login page? Or is my approach fundamentally wrong? Any 
>>> suggestions?
>>>   
>>
>> You can only force the redirect to a login page from the client-side.
>>
>> There's a couple of ways you can do this:
>>  - the interceptor can detect that the request is ajax either by the 
>> partitioning of your packages/URLs or by inspecting the http header;
>>  - return a custom http header when its an ajax request and 
>> unauthorized (eg. return a 2xx or 4xx with a custom X-param).  See the 
>> headers result type.
>>  - in your javascript callback, detect the odd result and perform a 
>> redirect
>>
>> Hope that helps.
>>
>> Jeromy Evans
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Interceptors-with-Ajax-Actions-tp15706322p15710190.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to