click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Schellink <sab...@gmail.com>
Subject Re: AW: [jira] Created: (CLK-568) Add ability to use templates with custom extensions
Date Thu, 16 Jul 2009 18:17:17 GMT
Hi Jozsef,

I've recently checked in a small change[1] to the XmlConfigService#isJsp 
implementation to make it more robust. With this change in place, your 
modification of performRender should not be necessary anymore.

kind regards

bob

[1]:http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/src/org/apache/click/service/XmlConfigService.java?r1=793525&r2=794701&diff_format=h

jozsef.gabor@bluewin.ch wrote:
> Hello. This is my favorite issue.
> 
> Currently I use a small hack in order to generate stylesheet from velocity template.
> Example: http://212.25.31.150/shop2/style.css
> 
> 
> First I tell the ClickServlet to trigger for special extensions in the deployment descriptor.
(web.xml).
> 
> 	<servlet-mapping>
> 		<servlet-name>SpringClickServlet</servlet-name>
> 		<url-pattern>*.htm</url-pattern>
> 		<url-pattern>/robots.txt</url-pattern>
> 		<url-pattern>/style.css</url-pattern>
> 	</servlet-mapping>
> 
> 
> 
> 
> 
> Small modification of performRender method in the ClickServlet is necessary.
> It is not perfect solution because it prevents using jsp pages. (IMHO jsp is a nightmare)
> 
>     /**
>      * Performs rendering of the specified page.
>      *
>      * @param page page to render
>      * @param context the request context
>      * @throws java.lang.Exception if error occurs
>      */
>     protected void performRender(Page page, Context context) throws Exception {
> 
>         final HttpServletRequest request = context.getRequest();
>         final HttpServletResponse response = context.getResponse();
> 
>         if (StringUtils.isNotBlank(page.getRedirect())) {
>             String url = page.getRedirect();
> 
>             url = response.encodeRedirectURL(url);
> 
>             if (logger.isTraceEnabled()) {
>                 logger.debug("   redirect: " + url);
> 
>             } else if (logger.isDebugEnabled()) {
>                 logger.debug("redirect: " + url);
>             }
> 
>             response.sendRedirect(url);
> 
>         } else if (StringUtils.isNotBlank(page.getForward())) {
>             // Indicates the request is forwarded
>             request.setAttribute(CLICK_FORWARD, CLICK_FORWARD);
> 
>             if (logger.isTraceEnabled()) {
>                 logger.debug("   forward: " + page.getForward());
> 
>             } else if (logger.isDebugEnabled()) {
>                 logger.debug("forward: " + page.getForward());
>             }
> 
>             if (page.getForward().endsWith(".jsp")) {
>                 renderJSP(page);
> 
>             } else {
>                 RequestDispatcher dispatcher =
>                     request.getRequestDispatcher(page.getForward());
> 
>                 dispatcher.forward(request, response);
>             }
> 
>         } else if (page.getPath() != null) {
>         	// MODIFICATION JGA ---------------------
>         	/*
>             String pagePath = page.getPath();
> 
>             // Check if request is a JSP page
>             if (pagePath.endsWith(".jsp") || configService.isJspPage(pagePath)) {
>                 // CLK-141. Set pagePath as the forward value.
>                 page.setForward(StringUtils.replace(pagePath, ".htm", ".jsp"));
> 
>                 // Indicates the request is forwarded
>                 request.setAttribute(CLICK_FORWARD, CLICK_FORWARD);
>                 renderJSP(page);
> 
>             } else {
>                 renderTemplate(page);
>             }
>             */
>             renderTemplate(page);
>             // MODIFICATION JGA ---------------------
> 
>         } else {
>             if (logger.isTraceEnabled()) {
>                 logger.debug("   path not defined for " + page.getClass().getName());
> 
>             } else if (logger.isDebugEnabled()) {
>                 logger.debug("path not defined for " + page.getClass().getName());
>             }
>         }
>     }
> 
> 
> 


Mime
View raw message