10 Replies Latest reply on May 10, 2010 5:55 PM by Matthew Lueck

    ajax4jsf-filter force-parser attribute not working

    Ryan McDonough Newbie

      We're experiencing a performance issue with Ajax4JSF with respect to its Tidy plugin. We've dome some profiling and we've found the class:


      org.ajax4jsf.webapp.FilterServletResponseWrapper.parseContent


      Is the biggest performance hog in the use case, consuming 90% of the process. I've tried to disable the tidy parser using components.xml by doing the following:


          <web:ajax4jsf-filter force-parser="false" />


      However, when we re-run the same tests, the profiling results are exactly the same each time. perhaps my understanding of this attribute is incorrect, but my hope was that it would not parse the entire page? If this is in correct, if we want to use the Neko parser, do we have to define it in web.xml?


      Ryan-

        • 1. Re: ajax4jsf-filter force-parser attribute not working
          Anikanchan Raut Newbie

          I work with Ryan and in addition to trying to suppress this filter, we also tried NEKO plugin for filter but it broke most of the RichFaces component. We added the filters in web.xml as following:


          In web.xml:


              <filter>
                  <display-name>RichFaces Filter</display-name> 
                  <filter-name>richfaces</filter-name> 
                  <filter-class>org.ajax4jsf.Filter</filter-class>
              </filter>
              <filter-mapping> 
                  <filter-name>richfaces</filter-name> 
                  <servlet-name>Faces Servlet</servlet-name>
                  <dispatcher>FORWARD</dispatcher> 
                  <dispatcher>REQUEST</dispatcher>
                  <dispatcher>INCLUDE</dispatcher> 
              </filter-mapping>
          .................
          .................
          
              <context-param>
                  <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
                  <param-value>NEKO,TIDY,NONE</param-value>
              </context-param>
              <context-param>
                  <param-name>org.ajax4jsf.xmlparser.TIDY</param-name>
                  <param-value>.*\..*</param-value>
              </context-param>
              <context-param>
                  <param-name>org.ajax4jsf.xmlparser.NEKO</param-name>
                  <param-value>/abc/xyz.xhtml</param-value>
              </context-param>
              <context-param>
                  <param-name>org.ajax4jsf.xmlparser.NONE</param-name>
                  <param-value>/pages/performance\.xhtml,/pages/default.*\.xhtml</param-value>
              </context-param>



          Idea was to parse xyz.xhtml under abc folder to be parsed using NEKO and rest of the xhtmls using TIDY. Any idea what we might be doing wrong? Thanks.

          • 2. Re: ajax4jsf-filter force-parser attribute not working
            Pete Muir Master

            the correct way to set the parser for a4j is in web.xml as you are doing,

            • 3. Re: ajax4jsf-filter force-parser attribute not working
              Anikanchan Raut Newbie

              Thanks Pete! So, if we are doing it right, what is the problem then? Why don't any of RichFaces component show up on the page. We have tried both IE and FF.

              • 4. Re: ajax4jsf-filter force-parser attribute not working
                Guillaume Jeudy Master

                This issue is specific to Richfaces, try posting in their forum you might have better luck.


                For my part i'm using:


                <context-param>
                            <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
                            <param-value>NONE</param-value>
                      </context-param>



                only because of bad TIDY performance. I figured these parsers are useful if the JSF HTML output is malformed XML. Since all my output is generated by either JSF tags or Richfaces tags declared in facelets with no pass-through HTML I figured it would have to be wellformed XML. Otherwise it would certainly mean some bug in UI tags in JSF or richfaces libraries.


                I tested my whole application with NONE set as above and the richfaces component render normally.


                I don't know if that is risky setup but if something blows up I might have to use TIDY parser as you are doing for certain pages.

                • 5. Re: ajax4jsf-filter force-parser attribute not working
                  Anikanchan Raut Newbie

                  I have tried this approach but I keep getting JavaScript error saying 'RichFaces can't be recognized'. Any idea how can I resolve it.


                  I have the same issue posted on RichFaces as well as Java Ranch forums.
                  My Link
                  My Link

                  • 6. Re: ajax4jsf-filter force-parser attribute not working
                    Guillaume Jeudy Master

                    Just to say, I encountered a situation today when my reRender would not work. I had to upgrade to NEKO instead of NONE to make it work.


                    Can you give more details on your richfaces setup? Maybe there's something wrong in it.


                    • 7. Re: ajax4jsf-filter force-parser attribute not working
                      Anikanchan Raut Newbie

                      Thanks for responding Guillaume.


                      Well to begin with, we are using Seam 2.0.1.GA and RichFaces 3.1.3.GA. All the dependencies are configured through root pom.xml.


                           <dependency>
                              <groupId>org.richfaces.framework</groupId>
                              <artifactId>richfaces-api</artifactId>
                              <version>3.2.0.SR1</version>
                            </dependency>
                            <dependency>
                              <groupId>org.richfaces.framework</groupId>
                              <artifactId>richfaces-impl</artifactId>
                              <version>3.2.0.SR1</version>
                            </dependency>
                            <dependency>
                              <groupId>org.richfaces.ui</groupId>
                              <artifactId>richfaces-ui</artifactId>
                              <version>3.2.0.SR1</version>
                            </dependency>
                            <dependency>
                              <groupId>org.richfaces.framework</groupId>
                              <artifactId>richfaces-test</artifactId>
                              <version>3.2.0.SR1</version>
                            </dependency>
                            <dependency>
                              <groupId>org.jboss.seam</groupId>
                              <artifactId>jboss-seam-remoting</artifactId>
                              <version>2.0.1.GA</version>
                            </dependency>
                            <dependency>
                              <groupId>org.jboss.seam</groupId>
                              <artifactId>jboss-seam</artifactId>
                              <version>2.0.1.GA</version>
                            </dependency>
                            <dependency>
                              <groupId>org.jboss.seam</groupId>
                              <artifactId>jboss-seam-ui</artifactId>
                              <version>2.0.1.GA</version>
                            </dependency>
                            <dependency>
                              <groupId>org.jboss.seam</groupId>
                              <artifactId>jboss-seam-debug</artifactId>
                              <version>2.0.1.GA</version>
                            </dependency>
                            <dependency>
                              <groupId>org.jboss.seam</groupId>
                              <artifactId>jboss-seam-ioc</artifactId>
                              <version>2.0.1.GA</version>
                            </dependency>




                      Each project below the root have their own pom.xml where we specify individually needed dependencies.


                              <dependency>
                                  <groupId>org.richfaces.framework</groupId>
                                  <artifactId>richfaces-api</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>org.richfaces.framework</groupId>
                                  <artifactId>richfaces-impl</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>org.richfaces.ui</groupId>
                                  <artifactId>richfaces-ui</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>org.jboss.seam</groupId>
                                  <artifactId>jboss-seam-remoting</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>org.jboss.seam</groupId>
                                  <artifactId>jboss-seam</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>org.jboss.seam</groupId>
                                  <artifactId>jboss-seam-ui</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>org.jboss.seam</groupId>
                                  <artifactId>jboss-seam-debug</artifactId>
                              </dependency>
                              <dependency>
                                  <groupId>org.jboss.seam</groupId>
                                  <artifactId>jboss-seam-ioc</artifactId>
                              </dependency>



                      I am specifying the filters I talked about earlier in web.xml for the project. I am not sure if this is what you were looking for. Let me know if I should provide you any more information.

                      • 8. Re: ajax4jsf-filter force-parser attribute not working
                        Guillaume Jeudy Master

                        ok well I'm not sure what could be wrong in your case, but anyway let me post my setup so you can compare with yours:
                        pom.xml for my war subproject:


                        <dependency>
                                 <groupId>org.richfaces</groupId>
                                 <artifactId>richfaces-api</artifactId>
                                 <version>3.2.1.GA</version>
                                 <scope>runtime</scope>
                        </dependency>
                        <dependency>
                             <groupId>org.richfaces</groupId>
                             <artifactId>richfaces-impl</artifactId>
                             <version>3.2.1.GA</version>
                             <scope>runtime</scope>
                        </dependency>
                        <dependency>
                             <groupId>org.richfaces</groupId>
                             <artifactId>richfaces-ui</artifactId>
                             <version>3.2.1.GA</version>
                             <scope>runtime</scope>
                        </dependency>



                        web.xml


                        <context-param>
                                  <param-name>org.richfaces.SKIN</param-name>
                                  <param-value>blueSky</param-value>
                             </context-param>
                        
                              <context-param>
                                    <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
                                    <param-value>NEKO</param-value>
                              </context-param>      
                        
                             <!-- load all richfaces javascript upfront -->
                             <context-param>
                                  <param-name>org.richfaces.LoadScriptStrategy</param-name>
                                  <param-value>ALL</param-value>
                             </context-param>
                             <context-param>
                                  <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
                                  <param-value>false</param-value>
                             </context-param>
                             <!-- load all richfaces css upfront -->
                             <context-param>
                                  <param-name>org.richfaces.LoadStyleStrategy</param-name>
                                  <param-value>ALL</param-value>
                             </context-param>
                             
                             <context-param>
                              <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                              <param-value>com.sun.facelets.FaceletViewHandler</param-value>
                            </context-param> 




                        I see some discrepancies with your web.xml and mine, try matching my config first then you can slowly make changes to see what works and what doesnt.


                        I don't think you need Richfaces filter setup.


                        Read Seam doc or Richfaces userguide. Seam2 listener is smart enough to detect the presence of richfaces on the classpath and dynamically install the filter for you. It may very well be possible your filter declaration is conflicting with Seam.

                        • 9. Re: ajax4jsf-filter force-parser attribute not working
                          Rob Hills Newbie

                          We're also seeing performance issues with many of our pages that the profiler seems to indicate is due to Ajax4JSF parsing.  I've got some web.xml context parameters that I believe should be excluding the pages I want, but logging suggests to me that these pages are still being parsed.


                          Did you get something working to your satisfaction?  If so, could you share the settings you used to get it working?

                          • 10. Re: ajax4jsf-filter force-parser attribute not working
                            Matthew Lueck Newbie

                            Does anyone have a solution to the performance of ajax4jsf's parsing?  I've tried NEKO as well.  The default seam pages use ajax4jsf support tag to verify individual fields.  If a user (or a set of users) tab quickly through each field on an 'edit' page, every CPU cycle on the box is used repeatedly parsing the document for each field tabbed through.  Is the best solution really just to remove ajax4jsf from the application?  If someone has a working components.xml and web.xml, could they please post them?  I've RTFM and tried various combinations to no avail.