Re: call java methods
"Ahmad J. Alhaj Hussein" <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
You can call java method by using the following points :-
1) Create new class the implements TemplateMethodModel interface
package com.araqa;
import java.util.List;
import freemarker.template.SimpleNumber;
import freemarker.template.TemplateMethodModel;
import freemarker.template.TemplateModelException;
public class FreeMarkerMethod implements TemplateMethodModel{
@Override
public Object exec(List arg0) throws TemplateModelException {
return new SimpleNumber(System.currentTimeMillis());
}
}
2) write the below command in the Freemaker template to call the exec(..)
method.
<#assign utility = "com.araqa.FreeMarkerMethod"?new() >
${utility("x")}
Best Regards,
Ahmad Alhaj Hussine
--
View this message in context: http://freemarker.624813.n4.nabble.com/call-java-methods-tp625908p3821825.html
Sent from the freemarker-user mailing list archive at Nabble.com.
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
http://p.sf.net/sfu/rim-devcon-copy2