I don't see anything obviously wrong with your Java from Javascript calls. Looking at some of my scripts, I see I follow cocoon.senPage() with a cocoon.exit() call. I sort-of recall getting an error without this in some cases, but I don't recall what sort of error.

Some other general debugging tips:

  You can run your javascripts using rhino from the shell.
The cocoon object doesn't exist and there are some other environment differences,
        but you can easily test the Date classes:


$ java -jar  /usr/local/java/rhino1_6R5/js.jar
Rhino 1.6 release 5 2006 11 18
js> var d = new java.util.Date();
js> d
Wed Jul 25 15:49:43 EDT 2007
js> d.year
107
js> d.year = 103
103
js> d
Fri Jul 25 15:49:43 EDT 2003
js> d.year = 2003
2003
js> d
Sat Jul 25 15:49:43 EDT 3903
js> ^D


  I see that the year values are actually  - 1900.
Looking at my java docs, I see that Date.getYear is marked as deprecated.
  Perhaps this is a problem if you are running Java 1.6
  ( I'm still using 1.5, so that's just a guess. )


You might also try adding some cocoon.log.info() calls to write debugging info
  to the cocoon log file.


A more complete example is included below at bottom.
( But, as noted, I don't think that is your problem. )
[ Example is a redirector I use to punt around the non-working
   unparsed-entity-uri() in cocoon problem by resolving the
   entities outside of cocoon's SAX event pipeline. ]

-- Steve.

On Jul 25, 2007, at 3:19 PM, Schmitz, Jeffrey A wrote:

 Hello,
   I've tried to call java from my flowscript as shown here:

http://cocoon.apache.org/2.1/userdocs/flow/java.html

However, I get a compilation error when I try to load my webpage. First,
is there anywhere to see specifics about the compilation error
encountered? All it tells me is Compilation produced 1 syntax error on
line 1.

Also, are there any more complete examples of calling java from
flowscript?

And finally, any ideas on what may be wrong?

Here's my main flowscript function, which otherwise works until I add
the java Date stuff:

function main()
{
   var d = new java.util.Date();
   d.year = 2003;    // same effect as d.setYear(2003);
   getInfo();
   upload();
var uri = neutralInstModel "/" + inputType + "In/" + inputFile + "/"
+ inputType + "In.trans/" + cocoon.continuation.id;
   cocoon.sendPage(uri);
}


importClass(Packages.org.xml.sax.helpers.DefaultHandler);
importClass(Packages.javax.xml.parsers.SAXParserFactory);

function unparsedEntityHandler( name, publicID, systemID, notat ) {
        this.entities[name] = systemID;
}


function getEntities( filename ) {
var hnd = { unparsedEntityDecl: unparsedEntityHandler, entities: {} };

        var spf = SAXParserFactory.newInstance();
        var p = spf.newSAXParser();
        var a = JavaAdapter( DefaultHandler, hnd );

        var xml = java.io.File( filename );

        p.parse( xml, a );

        return a.entities;

}


function redirector( ) {

        var document = cocoon.request.getParameter( 'document' );
        var entity = cocoon.request.getParameter( 'entity' );

    var ents = getEntities(  cocoon.parameters.context + document );
    cocoon.log.info( ents[entity] );

    cocoon.redirectTo( ents[entity], false );
    cocoon.exit();

}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to