Click Framework  History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: CLK-141
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Bob Schellink
Reporter: Huy Do
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Click

Page.setPath to JSP Pages not working

Created: 03/Nov/06 05:39 PM   Updated: 22/Apr/08 02:08 AM
Component/s: core
Affects Version/s: 1.4
Fix Version/s: 1.5 M1

File Attachments: 1. Text File ClickServlet.diff.txt (2 kb)

Environment: Linux Tomcat java 1.5


 Description  « Hide
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.

 All   Comments   Change History      Sort Order:
Malcolm Edgar [03/Nov/06 10:25 PM]
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

Huy Do [08/Mar/08 12:01 AM]
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.

Bob Schellink [20/Apr/08 10:11 PM]
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

Huy Do [21/Apr/08 11:15 AM]
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 [21/Apr/08 03:57 PM]
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.


Bob Schellink [22/Apr/08 02:08 AM]
Fixed in trunk. Will be available for 1.5M1.