Click
  1. Click
  2. CLK-468

Error on Redirect when 2 pages begins with the same characters

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.5.1
    • Component/s: core
    • Labels:
      None
    • Environment:
      apache, Linux, mySQL

      Description

      Hi,

      the setRedirect method with the target Page class doesn't work on a page which has the same beginners characters with another page
      In my case, i had 2 pages named PatindPage.class and PatindBOPage.class, their names have the same Patind characters.

      With Click 1.4 when i call the setRedirect(PatindBOPage.class), it works well but with Click 1.5, it doesn't find the path (404 error)
      If i try with the PatindPage.class, i have the same error, and finally if i try with ApatindBOPage.class it works.

        Activity

        Christophe FOIRET created issue -
        Hide
        Bob Schellink added a comment -

        Hi Christophe,

        I did a quick test but cannot produce it. Redirecting between two test pages PatindPage and PatindBOPage seems to work.

        Also the fact that you receive 404 seems to suggest a different problem. If Click cannot find a Page it will show the "Page not found" error: http://www.avoka.com/click-examples/general/missing.htm

        One thing you might want to do is clean and recompile your project and try again. Also look at the redirect URL generated in your browser. Why is it giving a 404? If you want you can post the redirect URL in a comment below.

        bob

        Show
        Bob Schellink added a comment - Hi Christophe, I did a quick test but cannot produce it. Redirecting between two test pages PatindPage and PatindBOPage seems to work. Also the fact that you receive 404 seems to suggest a different problem. If Click cannot find a Page it will show the "Page not found" error: http://www.avoka.com/click-examples/general/missing.htm One thing you might want to do is clean and recompile your project and try again. Also look at the redirect URL generated in your browser. Why is it giving a 404? If you want you can post the redirect URL in a comment below. bob
        Hide
        Christophe FOIRET added a comment -
        Show
        Christophe FOIRET added a comment - The bad redirect URL is http://localhost:8080/patindBO.htm instead of http://localhost:8080/patind/patindBO.htm
        Hide
        Bob Schellink added a comment -

        Ah interesting. Since the context path '/patind' and the page path '/patindBO.htm' have the same prefix '/patind' Click thinks the context is already part of the path and does not add it.

        We'll fix this for 1.5.1.

        In the meantime you can work around this by redirecting to the path instead of the page class.

        Or create a custom BorderPage override setRedirect with the following:

        public void setRedirect(String location) {
        if (location != null) {
        if (location.charAt(0) == '/') {
        Context context = getContext();
        String contextPath = context.getRequest().getContextPath();

        // CLK-468 - append trailing '/' in case context and path prefix is the same
        if (!location.startsWith(contextPath + '/'))

        { location = contextPath + location; }

        }
        }
        redirect = location;
        }

        Thanks.

        Show
        Bob Schellink added a comment - Ah interesting. Since the context path '/patind' and the page path '/patindBO.htm' have the same prefix '/patind' Click thinks the context is already part of the path and does not add it. We'll fix this for 1.5.1. In the meantime you can work around this by redirecting to the path instead of the page class. Or create a custom BorderPage override setRedirect with the following: public void setRedirect(String location) { if (location != null) { if (location.charAt(0) == '/') { Context context = getContext(); String contextPath = context.getRequest().getContextPath(); // CLK-468 - append trailing '/' in case context and path prefix is the same if (!location.startsWith(contextPath + '/')) { location = contextPath + location; } } } redirect = location; } Thanks.
        Hide
        Bob Schellink added a comment -

        fixed for 1.5.1

        Show
        Bob Schellink added a comment - fixed for 1.5.1
        Bob Schellink made changes -
        Field Original Value New Value
        Fix Version/s 1.5.1 [ 10090 ]
        Bob Schellink made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Henri Yandell made changes -
        Project Import Fri Mar 20 14:11:32 PDT 2009 [ 1237583492744 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Christophe FOIRET
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development