Greeting Page | Table Page | New Node Page | Form Page

This page shows how to add a span of HTML from an external resource into a page at runtime. The file addme.txt contains the HTML to be inserted.

If you can modify the HTML in the addme.txt, be sure that resulting span has valid tags. Missing end tags can cause the page to fail.

The html for the span is:
<span id="spanInsertHere">placeholder</span>
            
Below is the span with the inserted HTML:

placeholder that will be replaced

The following code shows how to insert an arbitrary string of HTML into a CDATA section. Using a CDATA section allows you to insert HTML that may not parse correctly but will still display as desired in a browser.
public NewNodeHTML createPage() {
    NewNodeHTML page = null;
    HTMLElement element = null;
    Node        newNode = null;
    String      fileContent = null;

    page = new NewNodeHTML();
    fileContent = readFile();
    newNode = page.createCDATASection(fileContent);
    element = page.getElementSpanInsertHere();
    element.getParentNode().replaceChild(newNode, element);
    return page;
}
            

Lutris | Enhydra

The Kelp Working Group