Click
  1. Click
  2. CLK-141

Page.setPath to JSP Pages not working

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.5 M1
    • Component/s: core
    • Labels:
      None
    • Environment:
      Linux Tomcat java 1.5

      Description

      Click servlet does not take JSP pages into consideration when rendering with a Page.getPath().

      eg. in your Page you have
      addModel("data", mydata)
      setPath("mypage.jsp")

      click uses renderTemplate() which only handles velocity templates.
      See attachment for my fix.

        Activity

        Huy Do created issue -
        Huy Do made changes -
        Field Original Value New Value
        Attachment ClickServlet.diff.txt [ 10130 ]
        Hide
        Malcolm Edgar added a comment -

        Hi Huy,

        with JSP pages you have to forward to them using setForward() as JSP are forward to via the request dispatcher.

        I dont think this is discussed in the documentation.

        regards Malcolm Edgar

        Show
        Malcolm Edgar added a comment - Hi Huy, with JSP pages you have to forward to them using setForward() as JSP are forward to via the request dispatcher. I dont think this is discussed in the documentation. regards Malcolm Edgar
        Malcolm Edgar made changes -
        Resolution Won't Fix [ 2 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Malcolm Edgar made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Hide
        Huy Do added a comment -

        I have a use case for this as follows. I have a report. MyReport.java with my-report.htm where display a form to gather report criteria. On submit, the MyReport validates the form, then loads the report data into the model using addModel("data", mydata). I then just want to render the report using jsp, by using setPath("my-report-data.jsp"). Using setForward will force me into having a backing MyReportData.java which in this case serves no purpose.

        Please reconsider this use case and see my attachment for a patch to fix this. Thanks.

        Show
        Huy Do added a comment - I have a use case for this as follows. I have a report. MyReport.java with my-report.htm where display a form to gather report criteria. On submit, the MyReport validates the form, then loads the report data into the model using addModel("data", mydata). I then just want to render the report using jsp, by using setPath("my-report-data.jsp"). Using setForward will force me into having a backing MyReportData.java which in this case serves no purpose. Please reconsider this use case and see my attachment for a patch to fix this. Thanks.
        Ahmed Mohombe made changes -
        Resolution Won't Fix [ 2 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        Bob Schellink made changes -
        Affects Version/s 1.4 [ 10011 ]
        Fix Version/s 1.5 M1 [ 10010 ]
        Hide
        Bob Schellink added a comment -

        Hi Huy,

        Will the attached patch work correctly when you have a template defined? If a path is specified e.g. "edit-customer.jsp" the patch will dispatch to this path instead of the template.

        What I am thinking is that if the path ends with .jsp, we should set the forward to this path instead.

        Will this work for you use case?

        regards

        bob

        Show
        Bob Schellink added a comment - Hi Huy, Will the attached patch work correctly when you have a template defined? If a path is specified e.g. "edit-customer.jsp" the patch will dispatch to this path instead of the template. What I am thinking is that if the path ends with .jsp, we should set the forward to this path instead. Will this work for you use case? regards bob
        Hide
        Huy Do added a comment -

        Hi Bob,

        The problem here is that I have one page which on entry loads a htm page and on post loads a jsp page. To get the template to work correctly, I would have to have a conditional in my getTemplate() method to know when to load my layout.htm or layout.jsp. This isn't nice. To really fix this problem, I think we need a setTemplate(String myTemplate) method as well. That way, your solution would work for me, because I could set the correct template.

        I'm currently not affected by this because I use sitemesh for my border templates.

        Regards,

        Huy

        Show
        Huy Do added a comment - Hi Bob, The problem here is that I have one page which on entry loads a htm page and on post loads a jsp page. To get the template to work correctly, I would have to have a conditional in my getTemplate() method to know when to load my layout.htm or layout.jsp. This isn't nice. To really fix this problem, I think we need a setTemplate(String myTemplate) method as well. That way, your solution would work for me, because I could set the correct template. I'm currently not affected by this because I use sitemesh for my border templates. Regards, Huy
        Bob Schellink made changes -
        Assignee Malcolm Edgar [ medgar ] Bob Schellink [ sabob ]
        Hide
        Bob Schellink added a comment -

        I have checked in some code to resolve this issue.

        When setting the path to a JSP, ClickServlet will check if the path has a jsp extension, and set this as the new forward value, effectively overriding the current forward value.

        Setting the path value should work when moving from htm to jsp as well as jsp to jsp.

        >To really fix this problem, I think we need a setTemplate(String myTemplate) method as well.

        Nods, having a Page#setTemplate seems like a good idea. I will add this tonight.

        Show
        Bob Schellink added a comment - I have checked in some code to resolve this issue. When setting the path to a JSP, ClickServlet will check if the path has a jsp extension, and set this as the new forward value, effectively overriding the current forward value. Setting the path value should work when moving from htm to jsp as well as jsp to jsp. >To really fix this problem, I think we need a setTemplate(String myTemplate) method as well. Nods, having a Page#setTemplate seems like a good idea. I will add this tonight.
        Hide
        Bob Schellink added a comment -

        Fixed in trunk. Will be available for 1.5M1.

        Show
        Bob Schellink added a comment - Fixed in trunk. Will be available for 1.5M1.
        Bob Schellink made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Bob Schellink made changes -
        Reporter Huy Do [ huydo ] Huy Do [ huy ]
        Henri Yandell made changes -
        Project Import Fri Mar 20 14:11:32 PDT 2009 [ 1237583492744 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        111d 22h 55m 1 Malcolm Edgar 24/Feb/07 00:35
        Resolved Resolved Closed Closed
        30d 21h 14m 1 Malcolm Edgar 26/Mar/07 22:49
        Closed Closed Reopened Reopened
        347d 10h 22m 1 Ahmed Mohombe 08/Mar/08 08:12
        Reopened Reopened Resolved Resolved
        45d 55m 1 Bob Schellink 22/Apr/08 10:08

          People

          • Assignee:
            Bob Schellink
            Reporter:
            Huy Do
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development