TemplateScript script;
TemplateLink link;
TemplateControl tctrl;
StringBuilder xhtml = new StringBuilder();
Template template = workspace.getTemplate();
try
{
// Confecciona la cabecera
xhtml.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">").append("\n");
xhtml.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"es\" lang=\"es\">").append("\n");
xhtml.append("<head>").append("\n");
xhtml.append(TAB_SEPARATOR + "<title>").append(page.getTitle()).append("</title>").append("\n");
xhtml.append(TAB_SEPARATOR + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=").append(page.getCharset()).append("\"></meta>").append("\n");
xhtml.append(TAB_SEPARATOR + "<meta name=\"generator\" content=\"" + Cosmo.COSMO_NAME + "\"></meta>").append("\n");
xhtml.append(TAB_SEPARATOR + "<meta name=\"uuid\" content=\"" + uuid + "\"></meta>").append("\n");
// Inserta Scripts y Links de la p�gina
Iterator<TemplateLink> itl = template.getLinks();
while (itl.hasNext())
{
link = itl.next();
xhtml.append(TAB_SEPARATOR + link.render());
}
Iterator<TemplateScript> its = template.getScripts();
while (its.hasNext())
{
script = its.next();
xhtml.append(TAB_SEPARATOR + script.render());
}
// Inserta Scripts y Links de los controles
for (Control ctrl : page.getCenterContents())
{
tctrl = template.getControl(ctrl.getControlTypeId());
if (tctrl != null)
{
for (TemplateLink tlink : tctrl.getLinks())
{
xhtml.append(TAB_SEPARATOR + tlink.render());
}
for (TemplateScript tscript : tctrl.getScripts())
{
xhtml.append(TAB_SEPARATOR + tscript.render());
}
}
}
// xhtml.append(" <link rel=\"stylesheet\" type=\"text/css\" href=\"templates/1/template.css\"></link>").append("\n");
xhtml.append("</head>").append("\n");
xhtml.append("<body>").append("\n");
// Obtiene la estructura
xhtml.append(template.getLayout(page.getLayout()));
Control.replaceTag(xhtml, TAG_SITE_NAME, workspace.getName());
// Widgets
renderLogin(workspace, xhtml, page);
renderMenus(workspace, xhtml, page);