[JBoss Seam] - Re: Seam Remoting - ajax request after session expires
by 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.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4076112#4076112
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4076112
18Â years, 9Â months
[JBoss Seam] - Re: Quartz configuration in Seam 2.0B
by pierospinelli
I'm making a control set program for an intranet scheduler.
The program allows to create a task definition (i.e. a name, a group, a Java class, a description, parameter definition with possibly default, required flag, ...), one or more Jobs for each definition (i.e. with different cron scheduling and different parameters).
It allows to control status (active/paused) of each job and of the whole scheduler, to see the log of each job and, if a job is running, to see its output in near real-time). More it allows to run other Job "one-shot" based on different values of terminating jobs.
I am currently using SEAM and JPA/Hibernate for the model. I'm using Quartz as the schedule engine with the in-memory configuration, so on application startup I have to read my model (using JPA) and recreate the active Jobs in Quartz.
I had a look to the table definitions of Quartz and I saw the they look very much similar to the tables generated for the persistent objects of my applications; so I wonder if it is not a waste of time/resources (if I use Quartz with DB configuration) using my custom tables when I could use directly the Quartz's ones. Just I'd like to continue using them by a persistent model (as I currently do) and not directly with JDBC.
This is the reason for I asked if Quartz already exposes a persistent model for its tables.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4076106#4076106
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4076106
18Â years, 9Â months