click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrey Rybin (JIRA)" <>
Subject [jira] Commented: (CLK-364) Port Velocity specific controls to Freemarker
Date Sun, 17 Jan 2010 12:55:54 GMT


Andrey Rybin commented on CLK-364:

First of all major bug must be fixed

I found these Velocity-only files in 


I can translate (already did, but untested) them to Freemarker, but Click need some refactoring
here for smooth support of both engines .

My suggestion is:

Both TemplateService.renderTemplate must try templatePath "as is" (i.e. .htm) and if not found
then fallback to its "native" file extension (.vm or .ftl).

All controls with external templates have both version: MyControl.vm and MyControl.ftl (not
.htm), so 
TemplateService will try MyControl.htm (exception will be thrown and caught internally), then
it will fallback to MyControl.ftl in case of FreemarkerTemplateService.

I.e.: (not tested):

  public void renderTemplate (Page page, Map model, Writer writer) throws Exception {
    final String pageTemplate = page.getTemplate();
    if (pageTemplate == null || pageTemplate.length() == 0) {
      throw new IllegalArgumentException("pageTemplate is empty: "+page);
    Template template;
    try {  // Get the default template object
      template = configuration.getTemplate(pageTemplate);
    } catch (FileNotFoundException e) {//fallback to .ftl
      final int i = pageTemplate.lastIndexOf('.');
      if (i == -1) { throw e; }

      template = configuration.getTemplate(pageTemplate.substring(0, i + 1) + "ftl");

    template.process(model, writer);// Merge the data-model and the template

Same changes must be done for second (overloaded) renderTemplate.

> Port Velocity specific controls to Freemarker
> ---------------------------------------------
>                 Key: CLK-364
>                 URL:
>             Project: Click
>          Issue Type: Improvement
>    Affects Versions: 1.5 M1
>            Reporter: Bob Schellink
>            Assignee: Bob Schellink
> There are a couple of controls which leverage Velocity templates for rendering. This
makes them unusable if Freemarker is used.
> A straightforward way of resolving this is to move the template code to the control's
toString method.
> Alternatively we must port the Velocity template to Freemarker and deploy that freemarker
templates at startup time.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message