Displaying content from Java External

Options

I'm trying to create a Java external to be used in a component. I want the helloElement attribute value and the text displayed in the component.

Here is my Java Code (it's a quite simple example):

package com.sayHello;

import com.interwoven.livesite.dom4j.Dom4jUtils;
import com.interwoven.livesite.runtime.RequestContext;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

public class HelloTeamsite {

    public static Document hello(RequestContext context) {

        Document doc = Dom4jUtils.newDocument();

        Element docElement = DocumentHelper.createElement("helloElement");

        docElement.addAttribute("isPolite", "Java is polite and is saying hello.");

        docElement.addText("Java is still trying to say hello.");

        doc.add(docElement);

        return doc;

    }
}

While creating my custom component, my Content XML data is:

<Data>
  <External>
    <Object Scope="local">com.sayHello.HelloTeamsite</Object>
    <Method>hello</Method>
  </External>
</Data>

When I preview the component, I notice that my hello method is called correctly and data is retrieved, as the Content XML area during the preview displays the "Java is still trying to say hello." message. The problem is that I can't present the data. I'm guessing something is wrong with my Appearance code:

<!DOCTYPE html-entities SYSTEM "http://www.interwoven.com/livesite/xsl/xsl-html.dtd">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!-- Skin: Default (Default Browser Type) -->
  <div>

    <xsl:value-of select=”/Properties/Data/Results/helloElement”/>

  </div>
</xsl:stylesheet>

Other trial and error attempts include:

<!DOCTYPE html-entities SYSTEM "http://www.interwoven.com/livesite/xsl/xsl-html.dtd">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!-- Skin: Default (Default Browser Type) -->

  <xsl:template match="/">
    <div>
      <xsl:apply-templates select="/Properties/Data/Result/helloElement" />
    </div>
  </xsl:template>

  <xsl:template match="helloElement">
    <div>
      <h2>
        <xsl:value-of select="isPolite" disable-output-escaping="yes"/>
      </h2>
    </div>
  </xsl:template>

</xsl:stylesheet>

Any help is appreciated.

Comments

  • Edit your component. Click preview. In the bottom pane of the window that pops up, there will be content XML structure (depending on your browser you may need to view source). Copy that into an XML editor and save it and run it through your XSL.

TeamSite Developer Resources

  • Docker Automation

  • LiveSite Content Services (LSCS) REST API

  • Single Page Application (SPA) Modules

  • TeamSite Add-ons

If you are interested in gaining full access to the content, you can register for a My Support account here.
image
OpenText CE Products
TeamSite
APIs