I solved it by refactoring the ViewFile to use list of actions (ViewAction) instead of its contents.
Since the projects I'm trying to generate so far have standard actions (displaying a message, assigning a value to a variable, redirecting to a page, etc), the ViewAction has an enum with the ActionType and a String with the value:
ViewAction
public class ViewAction {
private ActionType actionType;
private String value;
// getters and setters
}
ActionType
public enum ActionType {
DISPLAY,
ASSIGN,
BUTTON,
LINK,
CRUD
}
now I can use FreeMarker's <#include> directive according to the ActionType. This is less flexible, but now the Parser does not need to know how to code JSF views,
Plus it allowed to simplify my code even more. Instead of separating beans, views and models, I can define a single (or a list of) Model class and the JSFServiceFactory creates the services accordingly. Now the json for the HelloWorld app is way simpler:
{
"name":"simplehello",
"pomFile": {"groupId":"br.com.revo", "artifactId":"simplehello", "description":"the simplest JSF Project", "javaVersion":"1.7"},
"models":[
{"name":"Hello",
"scope":"VIEW",
"title":"Simple Hello",
"mainPage":true,
"fields":[{"type":"String", "name":"hello", "value":"\"Hello World!\""}],
"actions":[{"actionType":"DISPLAY", "value":"#{helloBean.hello}"}]
}
]
}