Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [JET]([JET] - samples using JET in a java app)
[JET] [message #915682] Mon, 17 September 2012 18:47
vinay Missing name is currently offline vinay Missing nameFriend
Messages: 1
Registered: September 2012
Junior Member
I am new to JET. I am looking to use it as a alternative to velocity as a templating framework in a java app.

From what I understand, you need to create a JET project to create java classes for the template, then you can 'run' the template (ie the generated java class for the template) - there could be one JET project which requires eclipse, however, one could run the template from a simple java project.

Came across

However, am not sure if I am following it correctly.

I was wondering if there were any samples that showed how to get it working in a java project (with info on which jars I would need to use in the java app)

I tried this in the java app, but get class not found exception in

* @param args
public static void main(final String[] args) {
_jet_banner htmlpage = new _jet_banner();
FileWriter output;
BufferedWriter writer;

JET2Context context = createJETContext(null, null);
JET2Writer out = new BodyContentWriter();

htmlpage.generate(context, out);

finalizeContent(out, null, null);



public static JET2Context createJETContext(final Object modelRoot, final Map<String, ?> variables) {

Map<String, Object> copiedVariables = new HashMap<String, Object>(variables != null ? variables
: Collections.<String, Object> emptyMap());

// ensure that c:iterate can set the XPath context object
copiedVariables.put("org.eclipse.jet.taglib.control.iterateSetsContext", Boolean.TRUE); //$NON-NLS-1$

final JET2Context context = new JET2Context(modelRoot, copiedVariables);

// this statement has the side effect of initializing tag handling
return context;

private static final void finalizeContent(final JET2Writer writer, final Object committedObject, final String existingContent)
throws JET2TagException {
final IWriterListener[] eventListeners = writer.getEventListeners();
for (IWriterListener eventListener : eventListeners) {
if (existingContent != null && eventListener instanceof IWriterListenerExtension) {
((IWriterListenerExtension) eventListener).finalizeContent(writer, committedObject, existingContent);
} else {
eventListener.finalizeContent(writer, committedObject);

Previous Topic:[Xtend/UML2] Resolving elements of a UML Profile.
Next Topic:[] DefaultCodeFormatterOptions not found
Goto Forum:

Current Time: Wed Oct 07 17:27:14 GMT 2015

Powered by FUDForum. Page generated in 0.02826 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software