StringBuilder result = new StringBuilder();
Sitemap sitemap = sitemapProvider.getSitemap(sitemapName);
try {
if(sitemap==null) {
throw new RenderException("Sitemap '" + sitemapName + "' could not be found");
}
logger.debug("reading sitemap {}", sitemap.getName());
if(widgetId==null || widgetId.isEmpty() || widgetId.equals("Home")) {
// we are at the homepage, so we render the children of the sitemap root node
String label = sitemap.getLabel()!=null ? sitemap.getLabel() : sitemapName;
EList<Widget> children = sitemap.getChildren();
if(poll && waitForChanges(children)==false) {
// we have reached the timeout, so we do not return any content as nothing has changed
res.getWriter().append(getTimeoutResponse()).close();
return;
}
result.append(renderer.processPage("Home", sitemapName, label, sitemap.getChildren(), async));
} else if(!widgetId.equals("Colorpicker")) {
// we are on some subpage, so we have to render the children of the widget that has been selected
Widget w = renderer.getItemUIRegistry().getWidget(sitemap, widgetId);
if(w!=null) {
if(!(w instanceof LinkableWidget)) {
throw new RenderException("Widget '" + w + "' can not have any content");
}
EList<Widget> children = renderer.getItemUIRegistry().getChildren((LinkableWidget) w);
if(poll && waitForChanges(children)==false) {
// we have reached the timeout, so we do not return any content as nothing has changed
res.getWriter().append(getTimeoutResponse()).close();