Apache FreeMarker - 1.0


Compatibility: v2 v3 Express
What's new? Release Notes
ID: com.castsoftware.java.freemarker

Description

This extension provides support for Apache FreeMarker Framework. 

In what situation should you install this extension?

If your Java application uses the Apache FreeMarker Framework and you want to view these object types and their links, then you should install this extension. More specifically the extension will identify:

  • “callLink” from HTML source code objects (.ftl and similar files) to CallToFTL objects.
  • “callLink” from CallToFTL objects to Java methods.

Technology support

Component Version Supported Supported Technology
Apache FreeMarker Framework 2.3.x Java

Transactions

Transaction support is derived from metamodel concepts used to build CAST Imaging Blueprint and structural transaction flows. Entry Points start transactions; Exit Points include both output/boundary concepts and Data Entities manipulated by transactions.

Role Support Breakdown
Entry Point No direct concept type details
Exit Point No direct concept type details

Data version: 1.0.0-funcrel

ISO 5055 Structural Rules

Quality support is based on ISO 5055 structural rules available for the selected extension version.

Reliability Maintainability Security Performance Efficiency

Data version: 1.0.0-funcrel

Download and installation instructions

The extension will not be automatically downloaded and installed in CAST Console. If you need to use it, should manually install the extension.

What results can you expect?

Objects

Icon Description
Java Freemarker FTL Parameter
Java Freemarker FTL Call 
Link Type Source and destination link
callLink Between HTML source code objects(.ftl and similar files) and CallToFTL objects.
callLink Between CallToFTL objects and JAVA methods.
relyonLink Between Java Freemarker FTLParameter and its JAVA class

Code Examples

MainTest.java

public static void main(String[] args) throws Exception {

        Configuration cfg = new Configuration();
        String content = null;

        cfg.setClassForTemplateLoading(MainTest.class, "templates");
        cfg.setIncompatibleImprovements(new Version(2, 3, 20));
        cfg.setDefaultEncoding("UTF-8");
        cfg.setLocale(Locale.US);
        cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

        Map<String, Object> input = new HashMap<String, Object>();

        input.put("title", "Dummy example");

        List<ValueExampleObject> systems = new ArrayList<ValueExampleObject>();
        systems.add(new ValueExampleObject("Android", "Google"));
        systems.add(new ValueExampleObject("iOS States", "Apple"));
        systems.add(new ValueExampleObject("Ubuntu", "Canonical"));
        systems.add(new ValueExampleObject("Windows7", "Microsoft"));
        input.put("systems", systems);

        Cal cal=new Cal();
        input.put("cal", cal);

        input.put("exampleObject", new ValueExampleObject("Java object", "me"));

        Template template = cfg.getTemplate("helloworld.ftl");

        template.process(input, consoleWriter);
}

Cal.java

public class Cal {
    public int add(int a, int b) {
        return a+b;
    }
    
    public int mul(int a, int b) {
        return a*b;
    }
}

helloworld.ftl

<html>
    
    <head>
      <title>${title}
    </head>
    <body>
      <h1>${title}</h1>
    
      <p>${exampleObject.name} by ${exampleObject.developer}</p>
    
      <ul>
        <#list systems as system>
          <li>${system_index + 1}. ${system.name} from ${system.developer}</li>
        </#list>
      </ul>
    
    <h1>
        2+3= ${cal.add(2,3)}
        10/2= ${cal.mul(10,2)}
    </h1>

    <#assign multiplied = cal.mul(40,20)>
    
    <h1>${multiplied}</h1>
    </body>
</html>