This content has been marked as final.
Show 4 replies
-
1. Here is the code
apg9595 Sep 14, 2009 4:41 PM (in response to apg9595)<head><script src="/IBIS/a4j/g/3_3_1.GA/org/ajax4jsf/framework.pack.js.faces" type="text/javascript"></script><script src="/IBIS/a4j/g/3_3_1.GA/org/richfaces/ui.pack.js.faces" type="text/javascript"></script><link class="component" href="/IBIS/a4j/s/3_3_1.GAorg/richfaces/renderkit/html/css/basic_both.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.f aces" rel="stylesheet" type="text/css" /><link class="component" href="/IBIS/a4j/s/3_3_1.GAorg/richfaces/renderkit/html/css/extended_both.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw_ _.faces" media="rich-extended-skinning" rel="stylesheet" type="text/css" /><link class="component" href="/IBIS/a4j/s/3_3_1.GA/org/richfaces/skin.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.faces" rel="stylesheet" type="text/css" /><script id="org.ajax4jsf.queue_script" type="text/javascript">if (typeof A4J != 'undefined') { if (A4J.AJAX) { with (A4J.AJAX) {if (!EventQueue.getQueue('org.rich faces.queue.global')) { EventQueue.addQueue(new EventQueue('org.richfaces.queue.global',null,null)) };}}};</script><script type="text/javascript">window.RICH_FACES_EXTENDED_SKINNING_ON=true;</script></head>
-
2. Re: Javascript error
nbelaevski Sep 14, 2009 5:35 PM (in response to apg9595)Hi,
1. It's required by components
2. Please post:
- pages code
- Java code that is actually used to do forward
- web.xml contents -
3. Re: Javascript error
smadhavan Sep 15, 2009 12:41 PM (in response to apg9595)thanx for your reply.
given below is the web.xml information<!-- Ajax for JSF filter --> <!-- --> <filter> <filter-name>richfaces</filter-name> <display-name>Ajax4jsf Filter</display-name> <filter-class>org.ajax4jsf.Filter</filter-class> <init-param> <param-name>forceparser</param-name> <param-value>false</param-value> </init-param> </filter> <filter> <filter-name>MyFacesExtensionsFilter</filter-name> <filter-class> org.apache.myfaces.webapp.filter.ExtensionsFilter </filter-class> </filter> <filter> <filter-name>extensionsFilter</filter-name> <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class> <init-param> <param-name>uploadMaxFileSize</param-name> <param-value>10m</param-value> <description>Set the size limit for uploaded files. Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB </description> </init-param> <init-param> <param-name>uploadThresholdSize</param-name> <param-value>100k</param-value> <description>Set the threshold size - files below this limit are stored in memory, files above this limit are stored on disk. Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB </description> </init-param> </filter> <!-- Application Specific Filter --> <filter> <filter-name>RequestIntercepter</filter-name> <filter-class>org.ets.ibis.web.filters.TimeoutFilter</filter-class> <init-param> <param-name>session</param-name> <param-value>user</param-value> </init-param> <init-param> <param-name>url</param-name> <param-value>/sessionTimeout.faces</param-value> </init-param> <init-param> <param-name>ignoreUrls</param-name> <param-value>login.faces,sessionTimeout.faces,logout.faces,/resources/,/xmlsvcs/,/services,/Word,/Export,/Report,/exportFiles/,/external/,/registration/</param-value> </init-param> </filter> <!-- ajax4jsf filter mapping--> <filter-mapping> <filter-name>richfaces</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages --> <filter-mapping> <filter-name>MyFacesExtensionsFilter</filter-name> <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry --> <servlet-name>Faces Servlet</servlet-name> </filter-mapping> <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) --> <filter-mapping> <filter-name>MyFacesExtensionsFilter</filter-name> <url-pattern>/faces/myFacesExtensionResource/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>RequestIntercepter</filter-name> <url-pattern>*.faces</url-pattern> </filter-mapping> <filter-mapping> <filter-name>RequestIntercepter</filter-name> <url-pattern>/publishingPipelineContent</url-pattern> </filter-mapping>
Java Code for the forward----TimeoutFilter.java... /** * Same contract as for doFilter, but guaranteed to be just invoked once per request. * * @param request * @param response * @param filterChain */ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { //no caching noCache(response); try { //validate against ignore urls property if(processRequestURI(request)) { long start = System.currentTimeMillis(); //get session attribute Object o = WebUtils.getRequiredSessionAttribute(request,session); logger.debug("Looking for session attribute -> " + session + " with value [" + o + "]"); if(o instanceof User) { User user = (User)o; //set current thread user ibisContext.setThreadUser(user); } else { logger.warn("Invalid session attribute [" + o + "]"); throw new IllegalStateException("Invalid session attribute!"); } //log it only when needed logger.debug("Total time to process the request - " + (System.currentTimeMillis()-start) + " ms"); } //process filterChain.doFilter(request, response); } catch (IllegalStateException e) { request.getRequestDispatcher(url).forward(request,response); //response.sendRedirect(request.getContextPath() + response.encodeRedirectURL(url)); return; } finally { //clean up after execution complete ibisContext.clearThreadUser(); } }
JSP Pages
sessionTimeOut.jsp<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <html> <head> <title>IBIS - Item Banking Information System</title> <link rel="stylesheet" type="text/css" href="resources/css/style.css" /> <link rel="stylesheet" type="text/css" href="resources/css/topBanner.css" /> <script language="javascript"> <!-- function breakFrames(){ if(top!= self) { top.location.href = self.location.href; } } //--> </script> </head> <body topmargin="0" leftmargin="3" rightmargin="0" marginheight="0" marginwidth="3" link="blue" alink="blue" vlink="blue" onload="breakFrames()"> <f:view> <h:form id="form" target=""> <div class="topBannerContainer" style="background-image:url(resources/images/3000-x-45-banner.GIF); background-repeat:no-repeat; background-color:EAF1FF; margin-bottom:1em;"> <img src="resources/images/Banner-w-logos.gif" border="0" alt='IBIS <h:outputText value="#{ibisBuildInfo}" />' /> </div> <div style="text-align: center;"> <div style="border:thin solid; width:600px; height:80px; position:relative; top:20px; padding:10px; border-color:#CCCCFF; border-width:1px; border-spacing:0px; margin-bottom:2em;"> <p style="text-align: center; font-weight: bold; font-size: 9pt; margin-bottom:1em;">Item Banking Information System</p> <p style="text-align: center; font-size: 9pt;">Unfortunately, your session has been terminated or timed out by the server. Please login again by clicking the button below.</p> </div> <div style="border: thin solid; width: 350px; position: relative; top: 20px; padding: 10px; border-color: #CCCCFF; border-width: 1px; border-spacing: 0px; background-color: #E8EEF7"> <table align="center" border="0" cellspacing="5" cellpadding="5"> <tr> <td colspan="2" align="center"><h:commandButton action="internalLogin" value="Login Again" styleClass="cmdBtnClass"/></td> </tr> </table> </div> </div> </h:form> </f:view> <!-- MYFACES JAVASCRIPT --> <script type="text/javascript"> //<![CDATA[ function getScrolling() { var x = 0; var y = 0; if (self.pageXOffset || self.pageYOffset) { x = self.pageXOffset; y = self.pageYOffset; } else if ((document.documentElement && document.documentElement.scrollLeft)||(document.documentElement && document.documentElement.scrollTop)) { x = document.documentElement.scrollLeft; y = document.documentElement.scrollTop; } else if (document.body) { x = document.body.scrollLeft; y = document.body.scrollTop; } return x + "," + y; } //]]> </script> </body> </html>
thanks. -
4. Re: Javascript error
smadhavan Sep 16, 2009 3:18 PM (in response to apg9595)How can we ignore certain URLs from the Ajax Filter processing. In my application, i want to ignore certain URLs and for that i have a custom filter class.
How can we do the same thing with the org.ajax4jsf.Filter. I am using the below given context param configuration<filter> <filter-name>richfaces</filter-name> <display-name>Ajax4jsf Filter</display-name> <filter-class>org.ajax4jsf.Filter</filter-class> <init-param> <param-name>forceparser</param-name> <param-value>false</param-value> </init-param> </filter> <context-param> <param-name>org.ajax4jsf.xmlparser.ORDER</param-name> <param-value>NEKO,TIDY,NONE</param-value> </context-param>
for my custom filter this is the configuration i have<filter> <filter-name>RequestIntercepter</filter-name> <filter-class>org.ets.ibis.web.filters.TimeoutFilter</filter-class> <init-param> <param-name>session</param-name> <param-value>user</param-value> </init-param> <init-param> <param-name>url</param-name> <param-value>/sessionTimeout.faces</param-value> </init-param> <init-param> <param-name>ignoreUrls</param-name> <param-value>login.faces,sessionTimeout.faces,logout.faces,/resources/,/xmlsvcs/,/services,/Word,/Export,/Report,/exportFiles/,/external/,/registration/</param-value> </init-param> </filter>
and the filter class code is given below/** * */ /** public class TimeoutFilter extends IbisFilter { /** * session name to look for */ private String session; /** * Reference context, for internal use only */ private IbisContext ibisContext; /** * forward url (Required) */ private String url; /** * Declares ignored URLs if any */ private String ignoreUrls; /** * Initialize all necessary dependencies * * @param ac Application context */ protected void initializeFilter(WebApplicationContext ac) throws ServletException { ibisContext = (IbisContext)ac.getBean("ibisContext"); Assert.notNull(ibisContext,"Ibis Context implementation was not set!"); } /** * default constructor defines * mandatory filter parameters */ public TimeoutFilter(){ addRequiredProperty("session"); addRequiredProperty("url"); } /** * Same contract as for doFilter, but guaranteed to be just invoked once per request. * * @param request * @param response * @param filterChain */ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { //no caching noCache(response); try { //validate against ignore urls property if(processRequestURI(request)) { long start = System.currentTimeMillis(); //get session attribute Object o = WebUtils.getRequiredSessionAttribute(request,session); logger.debug("Looking for session attribute -> " + session + " with value [" + o + "]"); if(o instanceof User) { User user = (User)o; //set current thread user ibisContext.setThreadUser(user); } else { logger.warn("Invalid session attribute [" + o + "]"); throw new IllegalStateException("Invalid session attribute!"); } //log it only when needed logger.debug("Total time to process the request - " + (System.currentTimeMillis()-start) + " ms"); } //process filterChain.doFilter(request, response); } catch (IllegalStateException e) { request.getRequestDispatcher(url).forward(request,response); //response.sendRedirect(request.getContextPath() + response.encodeRedirectURL(url)); return; } finally { //clean up after execution complete ibisContext.clearThreadUser(); } } /** * Validates request URI against ignoreUrls property, if matched session validation will not take place. * @param request * @return */ private boolean processRequestURI(HttpServletRequest request) { if(StringUtils.isEmpty(ignoreUrls)) return true; //see if there are more than one String requestURI = request.getRequestURI(); String[] urls = StringUtils.split(ignoreUrls, ','); for(int i = 0; i < urls.length; i++) { if(StringUtils.contains(requestURI, urls)) return false; } //proceed return true; } /** * Getter for the session property * @return the session */ public String getSession() { return session; } /** * Setter for property session * @param session the session to set */ public void setSession(String session) { this.session = session; } /** * Getter for the url property * @return the url */ public String getUrl() { return url; } /** * Setter for property url * @param url the url to set */ public void setUrl(String url) { this.url = url; } /** * Setter for the property ignore URLs (comma delimited if multiple) * @param ignoreUrls */ public void setIgnoreUrls(String ignoreUrls) { this.ignoreUrls = ignoreUrls; } /** * Ibis context setter * @param ibisContext */ public void setIbisContext(IbisContext ibisContext) { this.ibisContext = ibisContext; } }
for the order of applying the filter. but still i am not able to ignore URLs.
let me know any suggestions or hints for ignoring URLs from Ajax Filter.
Thanks in advance