ajax4jsfFilter - how to tweak it in Seam 2.1?
rhills Dec 10, 2008 4:08 AMProfiling of our app has suggested that we have a bottleneck with TIDY parsing of our .seam/.xhtml files. I've found various links in this forum and elsewhere, but I've found it difficult to work out what is the current best practice for controlling the ajax4jsfFilter. I've also not been successful in switching OFF parsing for our .seam/.xhtml files.
I found this resource interesting and apparently useful, though now a little old: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=117190&postdays=0&postorder=asc&start=0. In this thread, it's suggested that the ajax4jsfFilter can be switched off 'if your XHTML is valid' but that it should be done via settings in components.xml. In particular, it makes mention of a setting 'forceparser=false'. I've tried using a web:ajax4jsf-filter element in my components.xml with various permutations of forceparser and regex-url-pattern, but all I manage to do is totally trash the functionality of any pages using A4J forms.
The following thread on this forum is also useful: http://www.seamframework.org/Community/Ajax4jsffilterForceparserAttributeNotWorking#comment40208. It's much more recent and in it, Pete Muir says: 'the correct way to set the parser for a4j is in web.xml'.
I've now removed all web:ajax4jsf-filter elements from my components.xml and put the following into my app's web.xml:
<context-param> <param-name>org.ajax4jsf.xmlparser.ORDER</param-name> <param-value>NONE,NEKO</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.xmlparser.NONE</param-name> <param-value>.*\.xhtml|.*\.seam</param-value> </context-param>
AFAICT, this should disable all ajax4jsf parsing for .xhtml and .seam files, but any others should fall through to the NEKO parser. From my logs, the context params seem to be going through OK:
2008-12-10 11:21:23,052 INFO [org.jboss.seam.servlet.SeamFilter] Initializing filter: org.jboss.seam.web.ajax4jsfFilter 2008-12-10 11:21:23,130 DEBUG [org.ajax4jsf.webapp.BaseFilter] Init ajax4jsf filter with nane: Seam Filter 2008-12-10 11:21:23,130 DEBUG [org.ajax4jsf.webapp.BaseFilter] Init parameters : 2008-12-10 11:21:23,130 DEBUG [org.ajax4jsf.webapp.BaseXMLFilter] init XML filter service with class org.ajax4jsf.webapp.ConfigurableXMLFilter 2008-12-10 11:21:23,208 INFO [org.ajax4jsf.cache.CacheManager] Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory 2008-12-10 11:21:23,224 INFO [org.ajax4jsf.cache.LRUMapCacheFactory] Creating LRUMap cache instance using parameters: {com.sun.faces.responseBufferSize=500000, facelets.DEVELOPMENT=false, org.ajax4jsf.COMPRESS_SCRIPT=false, org.richfaces.SKIN=blueSky, com.sun.faces.compressViewState=true, com.sun.faces.injectionProvider=org.jboss.web.jsf.integration.injection.JBossInjectionProvider, com.sun.faces.displayConfiguration=true, org.richfaces.LoadScriptStrategy=ALL, facelets.BUFFER_SIZE=500000, org.richfaces.LoadStyleStrategy=ALL, com.sun.faces.serializeServerState=false, facelets.SKIP_COMMENTS=true, org.ajax4jsf.xmlparser.NONE=.*\.xhtml|.*\.seam, org.ajax4jsf.xmlparser.ORDER=NONE,NEKO, javax.faces.STATE_SAVING_METHOD=client, javax.faces.DEFAULT_SUFFIX=.xhtml} 2008-12-10 11:21:23,224 INFO [org.ajax4jsf.cache.LRUMapCacheFactory] Creating LRUMap cache instance of default capacity 2008-12-10 11:21:23,302 DEBUG [org.ajax4jsf.resource.InternetResourceService] Resources service initialized 2008-12-10 11:21:23,317 INFO [org.ajax4jsf.cache.CacheManager] Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory 2008-12-10 11:21:23,317 INFO [org.ajax4jsf.cache.LRUMapCacheFactory] Creating LRUMap cache instance using parameters: {com.sun.faces.responseBufferSize=500000, facelets.DEVELOPMENT=false, org.ajax4jsf.COMPRESS_SCRIPT=false, org.richfaces.SKIN=blueSky, com.sun.faces.compressViewState=true, com.sun.faces.injectionProvider=org.jboss.web.jsf.integration.injection.JBossInjectionProvider, com.sun.faces.displayConfiguration=true, org.richfaces.LoadScriptStrategy=ALL, facelets.BUFFER_SIZE=500000, org.richfaces.LoadStyleStrategy=ALL, com.sun.faces.serializeServerState=false, facelets.SKIP_COMMENTS=true, org.ajax4jsf.xmlparser.NONE=.*\.xhtml|.*\.seam, org.ajax4jsf.xmlparser.ORDER=NONE,NEKO, javax.faces.STATE_SAVING_METHOD=client, javax.faces.DEFAULT_SUFFIX=.xhtml} 2008-12-10 11:21:23,317 INFO [org.ajax4jsf.cache.LRUMapCacheFactory] Creating LRUMap cache instance of default capacity
However, when I hit the home page, logging entries suggest to me that it's still being parsed, albeit by the NEKO filter:
2008-12-10 12:03:42,301 DEBUG [org.ajax4jsf.webapp.BaseXMLFilter] create HTML/XML parser for content type: text/html; charset=UTF-8 2008-12-10 12:03:42,473 DEBUG [org.ajax4jsf.io.parser.FastHtmlParser] Parser reached state is StateManager.LT 2008-12-10 12:03:42,473 DEBUG [org.ajax4jsf.io.parser.FastHtmlParser] Parser reached state is StateManager.EXCLAM 2008-12-10 12:03:42,473 DEBUG [org.ajax4jsf.io.parser.FastHtmlParser] Parser reached state is StateManager.DOCTYPESTART ... lots of FastHtmlParser Parser reached state entries 2008-12-10 12:03:42,598 DEBUG [org.ajax4jsf.io.parser.FastHtmlParser] Parser reached state is StateManager.ELEMENT 2008-12-10 12:03:42,598 DEBUG [org.ajax4jsf.webapp.BaseXMLFilter] Parsing html total time 187ms 2008-12-10 12:03:42,598 DEBUG [org.ajax4jsf.webapp.BaseFilter] Finished request processing total time 8312ms for uri: /home.seam
Sorry for the long post, but I've been trying to figure this out for a long time now!