AnsweredAssumed Answered

DeclarativeWebScript and public methods

Question asked by alrice on Aug 13, 2008
Latest reply on Aug 13, 2008 by alrice
Hey this is neat!   Am I wastefully re-inventing something that is already possible in DeclarativeWebScript? I have some public  string manipulation methods in my DeclarativeWebScript subclass. I want to be able to call them from the javascript . AFAIK the methods are not exposed anywhere to the javascript so I decided to set a reference to the DeclarativeWebScript instance, in the model:
protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status) {

// put this object as well, so the javascript can
// access it's public methods
model.put("oJavaParent", this);

}
Then in the Java-backed web script ( javascript) I can call methods like this and it works.
var x = oJavaParent.mypublicmethod(s);
I assume this would really speed up things like string formatting and concatenation that need to be called frequently. Unless there is a cost to the javascript-java bridging. I don't know how one would profile it.

Outcomes