struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grish <gin1...@hotmail.com>
Subject Re: Interceptors with Ajax Actions
Date Wed, 27 Feb 2008 10:05:53 GMT

Well I tried all approaches but I had a small problem with the javascript
redirect approach: I perform an AJAX operation and my interceptor redirects
to a page which displays the error message and has an inline javascript to
redirect to the login page as suggested.

It works fine in firefox but in IE I simply get "undefined" in my div area.

I tried out something simple and had a result page with this javascript:

<script type="text/javascript">
<!--

    window.location.href = "/newbie/login.action";

//-->
</script>

Unfortunately it doesn't work. Any suggestions?



Grish wrote:
> 
> Thanks Jeromy!
> 
> Yeah that helped a lot! 
> 
> It seems that making a topic for all ajax operations a little more tedious
> than the basic approaches you've suggested. Although, I'm going to try
> them all out for the learning experience! 
> 
> Thanks Again!
> 
> 
> 
> 
> Jeromy Evans - Blue Sky Minds wrote:
>> 
>> 
>> Grish wrote:
>>> I'm using the ajax theme with my struts tags, based on the struts 2
>>> tutorial,  to implement ajax functionality. Where can I define my code
>>> to
>>> catch the result and perform a redirect? I apologize for my
>>> inexperience.
>>>
>>> I'm a little unclear on how to 
>>>   
>> hmm...ok, this is using Dojo 0.4 and it gets messy pretty quickly.  I'd 
>> probably use a different approach given that constraint but I'll come 
>> back to that issue in a moment.
>> 
>> Basically with the tags you have two options:
>>   - subscribe to a Topic for all of the ajax operations. There should be 
>> a topic for when the response is received or handling an error response.
>>   - use a custom handler that performs the posts. 
>> I don't recall the details because I don't use these tags any more.  
>> Topics are touched on at [1] and [2] but you're quite limited in 2.0.x 
>> compared to 2.1.x. 
>> Dojo may have some global events but you'll have to search the API.
>> 
>> Given that constraint, I'd use these basic approaches:
>>   - return an HTML fragment for failed ajax requests instructing the 
>> user to login with an appropriate link; and/or
>>   - return an HTML fragment that also contains inline javascript that 
>> performs a redirection to the login page.  Make sure you have 
>> separateScripts=false and executeScripts=true on all the dojo tags.
>> 
>> I consider the latter case a hack but it should work with this version 
>> of Dojo in all the relevant browsers.
>> 
>> Hope that helps!
>> 
>> [1] http://struts.apache.org/2.0.11/docs/ajax-tags.html
>> [2]http://struts.apache.org/2.0.11/docs/ajax-and-javascript-recipes.html
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> 

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


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message