[opencms-dev] Java Code in Template - Questions!

ambiesense at gmx.de ambiesense at gmx.de
Thu Mar 27 05:03:45 CET 2003


Hi,

I am wondering if the following would be possible.

I run a ownCodeExample which executed own java code within a content
template. Pages made from this template displayed text generated from this Java
class. Here the code of the java file:

import com.opencms.template.*;
import com.opencms.file.*;
import com.opencms.core.*;
import java.util.*;

public class OwnCode extends CmsXmlTemplate {
    public byte[] getContent(CmsObject cms, String templateFile, String
elementName, 
                             Hashtable parameters, String templateSelector)
throws CmsException {
        CmsXmlTemplateFile templateDocument =
getOwnTemplateFile(cms,templateFile, elementName, 
            parameters, templateSelector);
        templateDocument.setData("greeting", "from Ralf!");

        // DEBUG OUTPUT        
        System.out.println("My own code is running!!! :-)");
        
        return startProcessing(cms, templateDocument, elementName,
parameters, templateFile);
    }
}


Is it possible to access here other files, i.e. a XML file in the OpenCMS
virtual filesystem, process it with XERCES or somehow and output some results
with setData of CmsXmlTemplateFile ?

Does somebody has done something similar and do have code for that ?

Thanks a lot!
Ralf

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!




More information about the opencms-dev mailing list