private String layoutInitTemplate(final String template, String startBoundary, String endBoundary, String layoutPath)
throws AnnotationDescriptorNotFoundException, EvaluatorException, AnnotationNotRegisteredException,
AnnotationNotFoundException, TemplateFileNotFoundException, TemplateFileAccessException,
ConfigurationNotSetException, TagParserException {
JavaInspector inspector = new JavaInspector(Administrator.class);
Context context = new Context();
AFWeaver.registerAllAnnotations();
AFWeaver.setOpenVariableBoundaryIdentifier(startBoundary);
AFWeaver.setCloseVariableBoundaryIdentifier(endBoundary);
// set config (ignores fields)
Configuration configuration = new Configuration("NAME") {
@Override
public String getAbsolutePath() {
return "";
}
@Override
protected StringBuilder getTemplate(String fileTemplatePath, String prefix)
throws TemplateFileNotFoundException {
if (fileTemplatePath.contains("layout")) {
InputStream is = this.getClass().getResourceAsStream(fileTemplatePath);
String tagContent = "";
try {
tagContent = Files.readInputStream(is);
} catch (Exception e) {
e.printStackTrace();
}
// add to cache
return new StringBuilder(tagContent);
} else {
return new StringBuilder(template);
}
}
@Override
protected String getDelimiter() {
return File.separator;
}
};
configuration.addMapping(new Mapping("String", "path"));
configuration.addMapping(new Mapping("Long", "path"));
configuration.addMapping(new Mapping("Owner", "path"));
configuration.addMapping(new Mapping("Integer", "path"));
Settings settings = new Settings();
configuration.setSettings(settings);
context.setConfiguration(configuration);
context.setOrderAnnotation("com.codingcrayons.aspectfaces.annotations.UiFormOrder");
List<MetaProperty> metaProperties = inspector.inspect(context);
UIFragmentComposer composer = new UIFragmentComposer();
composer.addAllFields(metaProperties);
context.setLayout(layoutPath);
String out = composer.composeForm(context).getCompleteForm().toString();