}
public static void expandWidget(SecurityContext securityContext, Page page, DOMNode parent, String baseUrl, Map<String, Object> parameters) throws FrameworkException {
String _source = (String)parameters.get("source");
ErrorBuffer errorBuffer = new ErrorBuffer();
if (_source == null) {
errorBuffer.add(Widget.class.getSimpleName(), new EmptyPropertyToken(source));
} else {
// check source for mandatory parameters
Matcher matcher = threadLocalTemplateMatcher.get();
// initialize with source
matcher.reset(_source);
while (matcher.find()) {
String group = matcher.group();
String source = group.substring(1, group.length() - 1);
ReplacementInfo info = new ReplacementInfo(source);
ArrayList<String> options = info.getOptions();
String key = info.getKey();
Object value = parameters.get(key);
if (value == null) {
if (!options.isEmpty()) {
errorBuffer.add(Widget.class.getSimpleName(), new ValueToken(new StringProperty(key), options.toArray()));
} else {
errorBuffer.add(Widget.class.getSimpleName(), new EmptyPropertyToken(new StringProperty(key)));
}
} else {
// replace and restart matching process
_source = _source.replace(group, value.toString());
matcher.reset(_source);
}
}
}
if (!errorBuffer.hasError()) {
Importer importer = new Importer(securityContext, _source, baseUrl, null, 1, true, true);
importer.parse(true);
importer.createChildNodes(parent, page);