3 Replies Latest reply on Jan 7, 2009 2:01 AM by Norman Richards

    Facelets debug page and URL rewriting

    Stephen Friedrich Novice

      My pages use rewrite patterns in pages.xml to strip of the JSF extension.
      This works great in general.


      However <ui:debug> now fails.
      The URL it generates as a link to the facelets debug page still contains the *.seam suffix.


      Does anybody have a an idea for a solution/workaround?

        • 1. Re: Facelets debug page and URL rewriting
          Norman Richards Expert

          Unfortunately, that URL is generated in javascript, so there's nothing we can do on the seam side.  Facelets would need to call response.encodeURL() to make sure the rewriting happens.

          • 2. Re: Facelets debug page and URL rewriting
            Stephen Friedrich Novice

            Thanks for the answer. I have researched this a little bit more and found that you are about half right ;-)


            The URL is created in Java code and used to generate the JavaScript:


                public void encodeBegin(FacesContext faces) throws IOException {
            
                    String actionId = faces.getApplication().getViewHandler().getActionURL(faces, faces.getViewRoot().getViewId());
                    
                    StringBuffer sb = new StringBuffer(512);
                    sb.append("<script language=\"javascript\" type=\"text/javascript\">\n");
                    sb.append("//<![CDATA[\n");
                    sb.append("function faceletsDebug(URL) { day = new Date(); id = day.getTime(); eval(\"page\" + id + \" = window.open(URL, '\" + id + \"', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = 240,top = 212');\"); };");
                    sb.append("var faceletsOrigKeyup = document.onkeyup; document.onkeyup = function(e) { if (window.event) e = window.event; if (String.fromCharCode(e.keyCode) == '" + this.getHotkey() + "' & e.shiftKey & e.ctrlKey) faceletsDebug('");
                    sb.append(actionId);
            



            Unfortunately as you can see the Java code only calls getActionURL() and fails to call  ExternalContext.encodeActionURL().
            I will create an issue for facelets, but doubt that it will be fixed in the foreseeable future.
            There's another bug (a simple typo) that prevents the default facelets debug page to function correctly (the root node for the component tree never expands). That bug is about a year old.


            Maybe Seam could include an improved version of ui:debug?

            • 3. Re: Facelets debug page and URL rewriting
              Norman Richards Expert

              I'm not sure that would be very appropriate for seam.  I'm looking now to see if I can override the getActionURL code to perform rewriting.  I don't know if that's reasonable or if it's even correct in the larger sense, but it would solve at least some of these cases where getActionURL is called without calling the servlet encodeURL.