I appoligize if this has been mentioned before or if there is a better way
to fix these issues but I know some people have asked about so I just wanted
to contribute what I have done...
To fix the page to not automatically add the <body></body>:
In RunData.java change this method
public Document getPage()
{
pageSet = true;
if ( this.page == null ) {
this.page = (Document)new NoBodyTagDocument();
}
return this.page;
}
Create the NoBodyDocument as
public class NoBodyTagDocument extends org.apache.ecs.Document
{
public NoBodyTagDocument()
{
getHtml().addElement("body", new BodyWithoutTag());
}
public org.apache.ecs.html.Body getBody()
{
return (org.apache.ecs.html.Body) getHtml().getElement("body");
}
}
Create the BodyWithoutTag as
public class BodyWithoutTag extends org.apache.ecs.html.Body
{
public String createStartTag()
{
return "";
}
public String createEndTag()
{
return "";
}
}
Also, it looks like the WebMacroSiteLayout is "forgetting" what the layout
is if it is not the defaut... to fix this change this method in
WebMacroSiteLayout:
public void doBuild( RunData data )
throws Exception
{
/* Get the context needed by WebMacro. */
WebContext context = TurbineWebMacro.getContext( data );
/* Screen results. */
String returnValue = "";
/*
* First, generate the screen and put it in the context so we
* can grab it the layout template.
*/
String layoutTemplate = data.getTemplateInfo().getLayoutTemplate();
// ADD THIS LINE
ConcreteElement results = ScreenLoader.getInstance()
.eval(data, data.getScreen());
data.getTemplateInfo().setLayoutTemplate(layoutTemplate);
// ADD THIS LINE
if (results != null)
returnValue = results.toString();
/* Variable for the screen in the layout template. */
context.put("screen_placeholder", returnValue);
/*
* Variable to reference the navigation screen in the layout
* template.
*/
context.put("navigation", new WebMacroNavigation( data ));
/*
* Grab the layout template set in the WebMacroSitePage. If
* null, then use the default layout template ( done by the
* TemplateInfo object ).
*/
String templateName = data.getTemplateInfo().getLayoutTemplate();
// FIXME: This should be specified by looking at
//
services.TurbineTemplateService.default.layout.template=/default.wm
if (templateName == null)
templateName = "/default.wm";
/*
* Finally, generate the layout template and add it to the
* body of the Document in the RunData.
*/
data.getPage().getBody()
.addElement(TurbineWebMacro.handleRequest(context, "layouts" +
templateName));
}
}
----------------------------------------------------------------------------
------------------------------------
I also want to mention a couple of possible fixes...
The WebMacro Template directory in TurbineResources.properties seems to need
the full path instead of the relative path which the comments say.
The ECS Document object has inconsistent getBody & setBody methods.
The getBody returns the private property of the Document object
public Body getBody()
{
return(body);
}
The setBody sets the Body object in the private Html object.
public Document setBody(Body set_body)
{
html.addElement("body",set_body);
return(this);
}
When the page is created, if I remember correctly, the private Body object
is used, but there is no way to set that body since the Body object in the
Html object is used for setting the Body.
- Joe Hudson
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]