9 Replies Latest reply on Aug 5, 2009 3:23 PM by Owl Eye

    How to Remove context name without using UrlRewriteFilter

    Paolo Bernardi Newbie

      Hi,


      there is a way to remove the context name from the link
      generated by Seam (without using the outbound-rule of UrlRewriteFilter) ?


      thanks
      Paolo

        • 1. Re: How to Remove context name without using UrlRewriteFilter
          John Ament Master

          what do you mean by context name, the URL path that the web app is deployed to?  if so, you could just change the context path to / and update ROOT.war (assuming you're on jboss as) to have a jboss-web.xml that points to a different context.

          • 2. Re: How to Remove context name without using UrlRewriteFilter
            Paolo Bernardi Newbie

            first of all... i forgot to say that i'm on tomcat ... :)



            what do you mean by context name, the URL path that the web app is deployed to?

            yes



            if so, you could just change the context path to / and update ROOT.war

            actually i deployed the application on ROOT context to avoid this behaviour but
            i'm trying to split my big application in 3 smaller apps so i need to deploy them on different directory ...


            any ideas ?


            thanks
            Paolo



            • 4. Re: How to Remove context name without using UrlRewriteFilter
              Paolo Bernardi Newbie

              thanks for the reply but i'm in a more complicated situation because i have apache in front of tomcat to manage the vhosts ...


              ... so i think the only way is to tell Seam to not write the context name in the generated link or in the servlet response ...


              example


              <h:commandButton action="#{myBean.action}" />
              
              
              @Name("myBean")
              class MyBean {
              
               public String action() {
                  return "/test.xhtml";
               }
              
              }




              myBean.action will point to   /context-name/test.seam
              but i need to point to   /test.seam   only


              also when i use


              <s:link view="/test.xhtml" />



              the link will point to /context-name/test.seam
              i need that Seam will point to /test.seam



              • 5. Re: How to Remove context name without using UrlRewriteFilter
                Owl Eye Newbie

                Hi Paolo,


                did you solve this issue? I ask because I've a similar issue trying to hide the context path from the action URL, e.g. I want /system/Roles.jsf instead of /mycontext/system/Roles.jsf


                I think there is no attribute for commandButton to tell it using a given path instead of the context path. Is there a way to use relative URL that doesn't contain the real context path?


                Thanks,
                Joao

                • 7. Re: How to Remove context name without using UrlRewriteFilter
                  Owl Eye Newbie

                  Sorry, John, i also forgot to say that i'm on tomcat ... that's why I'm so interessed into the solution of this topic.


                  (I've seen the url-Tag in core-JSTL which has a context attribute which I could set to
                  context="/"
                  so that I can skip the automatic setting of a context path infront of my app path... I thought it would be useful having something similar in JSF as I've seen getActionURL method set's the real context path in all situations infront.)


                  I don't see the need using JavaScript on client side changing the froms' action URL with such a powerful framework JSF is. ... or am I missing any possibility? Thanks

                  • 8. Re: How to Remove context name without using UrlRewriteFilter
                    John Ament Master

                    I think the original poster was making the issue a bit more difficult than it needed to be.  using apache in front for vhosts doesn't disqualify you from using the context.xml configuration to set the individual context paths for your war file(s).  in fact, it's designed to since they have a shared context capability, so session state can be shared amongst them.


                    i'm not really sure what this has to do with javascript.

                    • 9. Re: How to Remove context name without using UrlRewriteFilter
                      Owl Eye Newbie

                      Well you're right, John, for Paolos' configuration with 3 apps working together, this could be a solution.


                      However, my configuration is similar, I've also apache with the difference that I use mod_rewrite in a mass hosting configuration. All apps are deployed into different context paths to tomcat with no need to "know of"/"communicate with" each other.
                      (mod_rewrite hides the apps' context path for the client and passes the request uri to mod_jk; the client never sees the context path)


                      There's just a management section that uses commandButton's which picks FacesContext in a getActionURL method concatenates context path with the viewid of the navigation-rule and writes it to the plain HTML code form tag:


                      <form id="Form" name="Form" method="post" action="/mycontext/system/Roles.jsf"> ... </form>



                      Having the context path, e.g. /mycontext, in the HTML forms' action attribute is what makes me a headache. (With JavaScript one can manipulate the action attributes' URL on client side but that couldn't be the solution.)


                      So, perhaps there is a way using relative path to prohibit this or is there only the solution creating a customized Handler for these commandButton's ... or perhaps manipulate the FacesContext...?


                      Thanks