3 Replies Latest reply on Sep 10, 2012 6:22 AM by v.bannur

    URL rewriting by AjaxViewHandler

    v.bannur

      Hello,

       

      I need to hide the actual URL of the application from the client browser.

       

      For ex: Actual URL is http://localhost:8080/b2c/abc/xyz/pqr.xhtml and I need to rewrite this URL to : http://localhost:8080/MyApplication

       

      For this I have used custom AjaxViewHandler (attached a file)

       

      In this class I have overide the getActionURL() method and rewriting the actual URL. Even though the actual URL is showing client browser (Still not hiding).

       

      Please help me anyone what wrong in my code.

        • 1. Re: URL rewriting by AjaxViewHandler
          v.bannur

          Any one help me please?

          • 2. Re: URL rewriting by AjaxViewHandler
            healeyb

            There are a couple of  established approaches to solving this problem:

             

            1. Use PrettyFaces http://ocpsoft.org/prettyfaces/

             

            2. If you have an apache web server fronting your application server you can use mod_rewrite to do anything you want

               with URLs. Be warned though that despite being functional and fast the apache configuration was designed in hell

               and has flames coming out of it, which is what happens to a lot of people when they first try to use it.

             

            Perhaps of more use is the fact that JSF always shows the URL of the last page, not the current page. What you can

            do is use a post-redirect-get pattern:

             

            <h:commandButton action="login.xhtml?faces-redirect=true"/>

             

            normally the browser would issue a POST request to the server when you click the button. With PRG the browser sends

            a POST request followed by a GET request. With PRG if you refresh the page only the GET is resent avoiding potential

            duplicate orders etc...

             

             

            Regards,

            Brendan.

             

             

             


            Freelance Java Enterprise Developer


            JSF Richfaces Ajax Java 6/7 (scjp) EE 6 HTML CSS JavaScript jQuery MySQL JPA Hibernate Eclipselink

            Spring Oracle SQL JPQL Sybase EJB CDI Glassfish Apache JAX-RS Primefaces UNIX Paypal and more..

            • 3. Re: URL rewriting by AjaxViewHandler
              v.bannur

              Thanks Brendanfor replying

               

              You mean to say there is no soution from the custom view handler?

               

              However I use faces-redirect=true for every navigation rule.

               

              I heared there are few issues with prettyfaces and richfaces A4J components. thats the reason i was looking with custom viewhandler.