You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by "Andrey Rybin (JIRA)" <ji...@apache.org> on 2010/01/17 13:55:54 UTC

[jira] Commented: (CLK-364) Port Velocity specific controls to Freemarker

    [ https://issues.apache.org/jira/browse/CLK-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12801392#action_12801392 ] 

Andrey Rybin commented on CLK-364:
----------------------------------

First of all major bug must be fixed https://issues.apache.org/jira/browse/CLK-606


I found these Velocity-only files in 

ColorPicker.htm
PickList.htm
TabbedForm.htm
ListPanel.htm
TabbedPanel.htm
error.htm

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);
    }///i
    
    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");
    }//t

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


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




> Port Velocity specific controls to Freemarker
> ---------------------------------------------
>
>                 Key: CLK-364
>                 URL: https://issues.apache.org/jira/browse/CLK-364
>             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.