logo       

Re: [xmlc] Headers and footers: msg#00010

java.enhydra.xmlc

Subject: Re: [xmlc] Headers and footers

Actually, the way I prefer to do this header/footer
stuff is working and avoids the "entire document
inclusion" bug.

I have my design.html that has my header and footer,
with a content div in the middle.
---
<html>
<head>
<title>Design template</title>
</head>
<body>
<div>
This is the header for <span id="siteName_1">Widgets
R Us</span>.
<hr/>
</div>
<div id="content"></div>
<div>
<hr/>
This is the footer for <span id="siteName_2">Widgets
R Us</span>.
</div>
</body>
</html>
---

And then, I have my page.html which defines a content
div. And my servlet loads and does dynamic
modification on both design.html and page.html, and
then uses Justin's nifty replace() method to replace
the content div in the design.html with the content
div from page.html. It also substitutes the <head>
tag to get title, css, and javascript information, and
then writes the design.html's dom to the response.
Works great! Even with the divs in both documents
having an id of "content". PROBABLY, it's still
exhibiting the "insert the whole damn document" bug,
but since that's what I want in this case, I don't
mind.

This method of inserting the content document into the
middle of the template document is preferred because
it allows for the content to be placed inside other
tags (like a <td>). Whereas if the header and footer
had to be complete xml entities themselves, you
couldn't place the content inside a table. Therefore
this method is more flexible.

Thanks for all your help, Justin and James,

Erik

P.S. More questions to come, I think... :-)

--- James Rochford <jrochford@xxxxxxxxx> wrote:

> Hate replying to my own posting but I think the
> problem can be solved
> using the second suggestion of my previous posting.
> Here it is again.
>
> It looks as if the <div id="header"> element of your
> page.html is no
> longer part of the output. I'm woundering if at
> compile time empty
> nodes are being eleminated from the XMLObject. You
> might also try the
> following. Make sure the div id from design.html is
> different from the
> id of the div in page.html.
>
> design.html
>
> <body>
> <div id="dynheader">header content</div>
> </body>
>
>
> Page.html
>
> <body>
> <div id="header">HEADER GOES HERE</div>
> </body>
>
> Actually leave the text "HEADER GOES HERE" in the
> div. Then after
> appending the dynheader element remove the first
> node. Just a thought.
>
> Node headerNode =
>
returnHtml.importNode(headerFooter.getElementHeader(),true);
> node.appendChild(headerNode);
> node.removeChild(node.getFirstChild());
>
> James
>
>
>
> James Rochford wrote:
>
> > Hmmmm...
> >
> > Unless I'm mistaken the following line should if
> working correctly
> > return only import the header element. Not sure
> why the whole
> > document would be imported. Maybe it has something
> to do with the fact
> > the the node being imported has the same id as the
> node it is getting
> > inserted into. Not sure. Anyone else see the
> problem here? Maybe try
> > changing the id value in your design.html to
> something like.
> >
> >
> > headerFooter.html
> >
> > <body>
> > <div id="dynheader">Header content</div>
> >
> > </body>
> >
> >
> > Node headerNode =
> >
>
returnHtml.importNode(headerFooter.getElementHeader(),true);
> > node.appendChild(headerNode);
> >
> > returnHtml.html
> >
> > <body>
> > <div id="header">
> > <div id="dynheader">Header Content</div>
> > </div>
> > </body>
> >
> >
> > It looks as if the <div id="header"> element of
> your page.html is no
> > longer part of the output. I'm woundering if at
> compile time empty
> > nodes are being eleminated from the XMLObject.
> You might also try the
> > following.
> >
> > design.html
> >
> > <body>
> > <div id="dynheader">header content</div>
> > <body>
> >
> >
> > Page.html
> >
> > <body>
> > <div id="header">HEADER GOES HERE</div>
> > </body>
> >
> > Actually leave the text "HEADER GOES HERE" in the
> div. Then after
> > appending the dynheader element remove the first
> node. Just a thought.
> >
> > Node headerNode =
> >
>
returnHtml.importNode(headerFooter.getElementHeader(),true);
> > node.appendChild(headerNode);
> > node.removeChild(node.getFirstChild());
> >
> >
> >
> >
> >
> >
> >
> >
> > Erik Rasmussen wrote:
> >
> >> --- James Rochford <jrochford@xxxxxxxxx> wrote:
> >>
> >>
> >>> 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);
> >>> }
> >>> }
> >>>
> >>
> >>
> >> When I do this, it's inserting the entire
> document
> >> starting from the specified div to the
> destination
> >> document. That's confusing. Let me show an
> >> example...
> >>
> >> My design.html: (the equiv of your
> headerFooter.html)
> >> ----
> >> <html>
> >> <head>
>
=== message truncated ===>
> --
> You receive this message as a subscriber of the
> xmlc@xxxxxxxxxxxxx mailing list.
> To unsubscribe:
> mailto:xmlc-unsubscribe@xxxxxxxxxxxxx
> For general help:
> mailto:sympa@xxxxxxxxxxxxx?subject=help
> ObjectWeb mailing lists service home page:
> http://www.objectweb.org/wws
>




____________________________________________________
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 xmlc@xxxxxxxxxxxxx mailing list.
To unsubscribe: mailto:xmlc-unsubscribe@xxxxxxxxxxxxx
For general help: mailto:sympa@xxxxxxxxxxxxx?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise