AnsweredAssumed Answered

JavaScript & Java classes

Question asked by dozyarmadillo on Oct 2, 2012
Latest reply on Oct 3, 2012 by dozyarmadillo
Hi there

I have some code that parses an Excel spreadsheet. There is a parse() method on my service that takes a NodeRef (which would point to the uploaded spreadsheet). It returns an object graph of POJOs. The method signature looks like this:

MyConfiguration parse(NodeRef workbook) throws MyException;

I wrapped this code in an Action and this works fine. I would now like to expose this same functionality via server side JS. I extended BaseProcessorExtension and registered the extension via Spring.

I have the following JS code:


myextn.parse(document);

This works. I see a bunch of debug logging in the logfile that confirms that the spreadsheet has been parsed and the values transposed into a MyConfiguration object.

Now if I try this..


var cfg = myextn.parse(document);
// should execute the method MyService.getSomeProperty()
logger.log(cfg.someProperty);

..this fails. The variable cfg is reported as being null even though I can see that the spreadsheet was parsed OK via logging.

Are there any restrictions re exposing custom Java objects in JS that I should be aware of?

Thanks

Mark

Outcomes