4 Replies Latest reply on Feb 8, 2008 3:46 AM by carlosgg

    Cookies and Ajax4SJF

      Hi,

      If I turn off the use of cookies in JBoss in the deploy/jboss-web.deployer/context.xml file:

      <Context cookies=" false "...


      Ajax4JSF stops working. It sends the same JSF page instead of the JavaScript code:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
       <html xmlns="http://www.w3.org/1999/xhtml">
       <head>
       <link rel="stylesheet" type="text/css" href="/ClientMng/css/metal/loginStyle.css" />
       <link rel="stylesheet" type="text/css" href="/ClientMng/css/metal/commons.css" />
      ...


      Any help on this?





        • 1. Re: Cookies and Ajax4SJF

          Did you try to use the regular h:commandButton or h:commandLink in this situation?

          RichFaces does not use cookies explicitly. Moreover, even JSF does not do it. Cookies is used by servlet container (in your case, it is a Tomcat incorporated into JBoss) to keep the session id between the request.

          If Cookies are turn on, they are used. Otherwise, the URL postfix is used.

          Actually, you just found a bug in Tomcat. Send it to them. Tomcat, even after you set the parameter in context.xml, continues to use Cookies instead of URL postfix based on the knowledge that browser still supports Cookies.

          We checked this case on our side. The JSF application returns back to normal is the Cookies for the same domain are cleaned up manually in the browser.

          • 2. Re: Cookies and Ajax4SJF

            Thanks for the comment Sergey.

            JSF if properly working, but Ajax4JSF isn't.

            I've tried with Glassfish, which I think that does not use Tomcat, and the same thing happens.

            In fact the URL rewriting is also working, I get the following URL:

            http://faramir.care.chg.net:8080/ClientMng/pages/objetivo/iuPopulations/PIU_Objetivo.jsf;jsessionid=cd3c7939d222e0ebcbfd836df5c8


            And all the pages are displayed as they are supposed, but those ones using Ajax4JSF doesn't load the Ajax4JSF Script: "org.ajax4jsf.framework.ajax.AjaxScript.jsf" so I get the following error:
            syntax error
            [Break on this error] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or...

            And then of course I get an "A4J is not definet" Javascript error.




            • 3. Re: Cookies and Ajax4SJF
              wbossons

              Regarding the first issue, I believe Glassfish is built on top of TomCat.

              Regarding the ajax is not defined issue, I am using Glassfish also and had the same issue for my j2ee application where the ajax script pointer was not getting rendered. It was working correctly in a web app that I had also deployed on Glassfish, so I copied the pointer, modified it to point to my context path, and that got rid of the a4j is not defined errors.

              I'm using SUN RI, but you probably can do something similar ...

              <ui:script url='/faces/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript'/>

              ..\W

              • 4. Re: Cookies and Ajax4SJF

                Thank you wbossons,

                I don't know the ui:script TAG, I'm using the 'ui' prefix for Facelets and I think that the 'script' tag isn't in it.

                By the way, I managed to solve the issue with your hint. The problem is that Ajax4JSF is attaching the Ajax script in the following way:

                <script type="text/javascript" src="/JP050/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf">

                While, as it is a '.jsf' file and no cookies are used to track sessions, the web server needs the session ID at the end of the URL:
                <script type="text/javascript" src="/JP050/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf;jsessionid=D242FAF1CF130DA0A5AF3CDBE106DD43">

                So that was my solution, add the ajax4JSF script with the session ID.

                Again, thank you very much for your help.

                Carlos.