-
1. Re: Seam Remoting - ajax request after session expires
urosmil Aug 3, 2007 11:36 AM (in response to urosmil)Just to add: I am using Seam 1.2.1 GA.
-
2. Re: Seam Remoting - ajax request after session expires
monkeyden Aug 4, 2007 7:05 PM (in response to urosmil)BUMP
I'd like the know the elegant solution for this too. Seems to me that the request itself would keep the session alive, rather than simply querying for remaining time left, if any. -
3. Re: Seam Remoting - ajax request after session expires
urosmil Aug 6, 2007 9:42 AM (in response to urosmil)Hi.
Me again.
Is it possible that Seam engineers overlooked this real life situation?
Do you have some recommendation?
Would this be fixed in Seam 2.0?
I really enjoy working with Seam so I hope you would understand this as my attempt to help.
Thanks,
Uros! -
4. Re: Seam Remoting - ajax request after session expires
livenow Aug 7, 2007 5:28 AM (in response to urosmil)hi, it's better to post such thinks in Jira
http://jira.jboss.org/jira/browse/JBSEAM
as it may be overlooked here.
cheers,
livenow -
5. Re: Seam Remoting - ajax request after session expires
pmuir Aug 7, 2007 6:01 AM (in response to urosmil)JIRA is for feature requests and bugs with Seam. Please do not post support requests there. These issues will just be closed with a comment to ask on the forum.
-
6. Re: Seam Remoting - ajax request after session expires
urosmil Aug 7, 2007 8:04 AM (in response to urosmil)Hi Pete,
but isn't this feature that's missing (or bug)?
I wouldn't post this in JIRA if you think this doesn't belongs there!
Thanks,
Uros! -
8. Re: Seam Remoting - ajax request after session expires
urosmil Aug 21, 2007 2:46 AM (in response to urosmil)Hi,
I am back with my solution for this issue.
This is what I did to solve problem (I hope this can help someone):
SERVER SIDE:
1) Create Filter:public class SeamRemotingSessionValidationFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException {} public void destroy() {} public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpSession session = ((HttpServletRequest)request).getSession(); String servletPath = ((HttpServletRequest) request).getServletPath(); if( servletPath.startsWith("/seam/resource") && ( session.getAttribute( "loged" ) == null || !((String)session.getAttribute( "loged" )).equals("true") ) ) { ((HttpServletResponse)response).getWriter().append("<redirectPage to='startpage.jsf'/>"); return; } chain.doFilter(request, response); } }
Code "session.getAttribute( "loged" )" is my indicator for sassion.
2) Register Filter in web.xml:<filter> <filter-name>SeamRemotingSessionValidationFilter</filter-name> <filter-class> com.yc.isystem.presentation.filter.SeamRemotingSessionValidationFilter </filter-class> </filter> <filter-mapping> <filter-name>SeamRemotingSessionValidationFilter</filter-name> <url-pattern>/seam/resource/remoting/*</url-pattern> </filter-mapping>
CLIENT SIDE:
I decide not to change seam's js libraries so I used Javascript AOP (Aspect Oriented Programing). We already use dojotoolkit in our project so I used dojo's aop functions (there are other libraries which are created just for aop - search google for "js aop"). Next steps are explanation for dojo's aop functionalities.
3) Import dojo and set required library:<script src="#{facesContext.externalContext.requestContextPath}/js/dojo/dojo.js" language="javascript"></script> <script> dojo.require("dojo.event"); </script>
4) Set around advice:dojo.event.connect('around', Seam.Remoting, 'processResponse', 'ajaxResponseInterceptor');
I put this in html body (tag) onload='--here--' (attribute) but you can put where you need it.
5) Create js function for redirection:function ajaxResponseInterceptor(invocation){ if(invocation.args[0].firstChild.tagName == 'redirectPage'){ window.location = invocation.args[0].firstChild.attributes['to'].nodeValue; } var result = invocation.proceed(); return result; }
For some other js aop library steps would be same!
If you have problems adding this to you project feel free to ask for help - I'll help if I can.
IMPORTANT: This is first version so it's possible that there are some issues. If you seen some please inform me.
Thanks,
Uros.