Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5 RC2
    • Fix Version/s: 1.5 RC3
    • Component/s: None
    • Labels:
      None

      Description

      Hi, since the setRedirect logic was moved to the Page control...
      we must validate to guarantee that the "contextPath" will not be appended to the url twice.

      if you call setRedirect() two times (i know it´s strange but it´s possible), it will duplicate the contextPath...

      This is how I fixed this for my app:

      /**

      • @see net.sf.click.Page#setRedirect(java.lang.String)
        */
        public void setRedirect(String location) {
        if (location != null) {
        if (location.charAt(0) == '/')
        Unknown macro: { Context context = getContext(); String contextPath = context.getRequest().getContextPath(); if(!location.startsWith(contextPath)){ location = contextPath + location; } }

        }
        redirect = location;
        }

        Activity

        Hide
        Bob Schellink added a comment -

        Do you mean setRedirect(getRedirect()) will append the context multiple times?

        Because invoking setRedirect multiple times with a location seems to work:

        public void onInit()

        { setRedirect("/test.htm"); setRedirect("/test.htm"); }

        This produced '/mycontext/test.htm'

        Show
        Bob Schellink added a comment - Do you mean setRedirect(getRedirect()) will append the context multiple times? Because invoking setRedirect multiple times with a location seems to work: public void onInit() { setRedirect("/test.htm"); setRedirect("/test.htm"); } This produced '/mycontext/test.htm'
        Hide
        Ricardo R. Lecheta added a comment -

        Hi Bob,

        yes you are right.

        but if the redirect already have the context ?

        public void onInit()

        { setRedirect("/myContext/test.htm"); setRedirect("/myContext/test.htm"); }

        this happened to me, because I wrote some crazy logic to create some redirect String

        i know it looks strange, but it´s possible. I just think we should handle it...

        Show
        Ricardo R. Lecheta added a comment - Hi Bob, yes you are right. but if the redirect already have the context ? public void onInit() { setRedirect("/myContext/test.htm"); setRedirect("/myContext/test.htm"); } this happened to me, because I wrote some crazy logic to create some redirect String i know it looks strange, but it´s possible. I just think we should handle it...
        Hide
        Bob Schellink added a comment -

        Thanks for the pickup Ricardo. Fixed in trunk

        Show
        Bob Schellink added a comment - Thanks for the pickup Ricardo. Fixed in trunk

          People

          • Assignee:
            Bob Schellink
            Reporter:
            Ricardo R. Lecheta
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development