Re: [xmlc] Headers and footers
James Rochford <[email protected]> Thu, 01 Sep 2005 08:49:29 -0600
| Newsgroups | gmane.comp.java.enhydra.xmlc |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format...
------------=_1125586366-4880-133
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hello Eric,
I am currently using a dynamic header and footer. My approach is a
little different but perhaps it will work for you. I'm using a custom
framework but the premise is the same. All the pages in our site are
passed to a handler that inspects the XMLObject for a particular div in
this case <div id="header">. Sort of a "post processor" for the view
where content that is the same across all pages gets added. Hope this
helps.
class RenderView{
// object that contains getters for the request and response.
private HttpComs httpCom;
...
public XMLCFactory getFactory(){
XMLCFactory factory =
XMLCContext.getContext(httpCom.getServlet()).getXMLCFactory();
return factory;
}
public void drawheader(XMLObject returnHtml){
// Get the page containing the header and footer.
headerFooterHTML headerFooter
=(headerFooterHTML)this.getFactory().create(headerFooterHTML.class);
...
Update the header content
...
// Get the node in the return html where I want to insert the
header. Import the header node
// from the headerFooter. Append the node to the <div
id="header"> element.
Node node = returnHtml.getElementById("header");
if(node != null){
Node headerNode =
returnHtml.importNode(headerFooter.getElementHeader(),true);
node.appendChild(headerNode);
}
XMLCContext xmlc = XMLCContext.getContext(httpCom.getServlet());
OutputOptions outo =
xmlc.createOutputOptions(httpCom.getRequest(),
httpCom.getResponse(),returnHtml);
outo.setPrettyPrinting(true);
xmlc.writeDOM(httpCom.getRequest(), httpCom.getResponse(),
outo ,returnHtml);
}
}
Best regards
James Rochford
[email protected]
Erik Rasmussen wrote:
>I can only think of two ways to achieve common headers
>and footers on a web page generated with XMLC, and
>neither works:
>
>1) The built-in SSI mechanism. This will load in a
>header.html and footer.html into the top and bottom of
>your web page wherever you put the SSI directives
>BEFORE running the XMLC interface generation. So lets
>say I have index.html and products.html, and I have a
><span id="siteName">site</span> in my header.html that
>both index.html and products.html include. So I'll
>get interfaces indexHTML and productsHTML, both of
>which will have a method setTextSiteName(). But
>because they don't extend a common interface with that
>method, my code to set the site name has to use
>reflection to call the setTextSiteName() method. That
>sucks.
>
>2) DOM import. Say I make a file called template.html
>that contains my header and footer information in it,
>and has a <div id="content"> in the middle of it where
>I want my page content to go. I can set my dynamic
>header content with my templateHTML interface, and I
>can set my dynamic page content with my productsHTML
>interface. And then I can say:
>
>Element contentDiv =
>templateXmlObj.getElementContent();
>Node migratedContent =
>contentDiv.getDocument().importNode(productsXmlObj,
>true);
>contentDiv.appendChild(migratedContent);
>
>...and then just write the templateXmlObj to the
>response with the content from the products page
>inserted. Right? Wrong. Line 2 above throws a:
>org.w3c.dom.DOMException: Node type being imported is
>not supported
> at
>org.enhydra.apache.xerces.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:1049)
> at
>org.enhydra.apache.xerces.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:860)
>
>So wtf? Surely someone has succeeded in creating a
>webapp based on XMLC with common (and dynamic!) header
>and footer code. What am I missing? Is there another
>way?
>
>Thanks,
>Erik
>
>
>
>____________________________________________________
>Start your day with Yahoo! - make it your home page
>http://www.yahoo.com/r/hs
>
>
>
>
>------------------------------------------------------------------------
>
>
>--
>You receive this message as a subscriber of the [email protected] mailing list.
>To unsubscribe: mailto:[email protected]
>For general help: mailto:[email protected]?subject=help
>ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
------------=_1125586366-4880-133
Content-Type: text/plain; name="message-footer.txt"
Content-Disposition: inline; filename="message-footer.txt"
Content-Transfer-Encoding: 8bit
--
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
------------=_1125586366-4880-133--