Added JavaScript function stub to Node.prefetchChildren().
This commit is contained in:
parent
abd0b867b3
commit
b6f8c5edb3
2 changed files with 60 additions and 1 deletions
|
@ -189,6 +189,36 @@ public class ESNode extends ObjectPrototype {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefetch child objects from (relational) database.
|
||||||
|
*/
|
||||||
|
public void prefetchChildren (ESValue args[]) throws Exception {
|
||||||
|
checkNode ();
|
||||||
|
if (!(node instanceof Node))
|
||||||
|
return;
|
||||||
|
int start = 0, length = 0;
|
||||||
|
try {
|
||||||
|
if (args.length == 0) {
|
||||||
|
start = 0;
|
||||||
|
length = 1000;
|
||||||
|
} else if (args.length == 2) {
|
||||||
|
if (args[0].isNumberValue ())
|
||||||
|
start = args[0].toInt32 ();
|
||||||
|
else
|
||||||
|
throw new RuntimeException ("Illegal argument in prefetchChildren: "+args[0]);
|
||||||
|
if (args[1].isNumberValue ())
|
||||||
|
length = args[1].toInt32 ();
|
||||||
|
else
|
||||||
|
throw new RuntimeException ("Illegal argument in prefetchChildren: "+args[1]);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException ("Wrong number of arguments in prefetchChildren");
|
||||||
|
}
|
||||||
|
} catch (Exception x) {
|
||||||
|
throw new IllegalArgumentException (x.getMessage());
|
||||||
|
}
|
||||||
|
((Node) node).prefetchChildren (start, length);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This used to be different from add(), it isn't anymore. It's left here for
|
* This used to be different from add(), it isn't anymore. It's left here for
|
||||||
* compatibility.
|
* compatibility.
|
||||||
|
|
|
@ -82,6 +82,7 @@ public final class HopExtension {
|
||||||
esNodePrototype.putHiddenProperty ("href", new NodeHref ("href", evaluator, fp));
|
esNodePrototype.putHiddenProperty ("href", new NodeHref ("href", evaluator, fp));
|
||||||
esNodePrototype.putHiddenProperty ("setParent", new NodeSetParent ("setParent", evaluator, fp));
|
esNodePrototype.putHiddenProperty ("setParent", new NodeSetParent ("setParent", evaluator, fp));
|
||||||
esNodePrototype.putHiddenProperty ("invalidate", new NodeInvalidate ("invalidate", evaluator, fp));
|
esNodePrototype.putHiddenProperty ("invalidate", new NodeInvalidate ("invalidate", evaluator, fp));
|
||||||
|
esNodePrototype.putHiddenProperty ("prefetchChildren", new NodePrefetch ("prefetchChildren", evaluator, fp));
|
||||||
esNodePrototype.putHiddenProperty ("renderSkin", new RenderSkin ("renderSkin", evaluator, fp, false, false));
|
esNodePrototype.putHiddenProperty ("renderSkin", new RenderSkin ("renderSkin", evaluator, fp, false, false));
|
||||||
esNodePrototype.putHiddenProperty ("renderSkinAsString", new RenderSkin ("renderSkinAsString", evaluator, fp, false, true));
|
esNodePrototype.putHiddenProperty ("renderSkinAsString", new RenderSkin ("renderSkinAsString", evaluator, fp, false, true));
|
||||||
esNodePrototype.putHiddenProperty ("clearCache", new NodeClearCache ("clearCache", evaluator, fp));
|
esNodePrototype.putHiddenProperty ("clearCache", new NodeClearCache ("clearCache", evaluator, fp));
|
||||||
|
@ -245,6 +246,24 @@ public final class HopExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class NodePrefetch extends BuiltinFunctionObject {
|
||||||
|
NodePrefetch (String name, Evaluator evaluator, FunctionPrototype fp) {
|
||||||
|
super (fp, evaluator, name, 0);
|
||||||
|
}
|
||||||
|
public ESValue callFunction (ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {
|
||||||
|
try {
|
||||||
|
ESNode esn = (ESNode) thisObject;
|
||||||
|
esn.prefetchChildren (arguments);
|
||||||
|
} catch (IllegalArgumentException illarg) {
|
||||||
|
throw illarg;
|
||||||
|
} catch (Exception x) {
|
||||||
|
// swallow exceptions in prefetchChildren
|
||||||
|
}
|
||||||
|
return ESNull.theNull;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class NodeEditor extends BuiltinFunctionObject {
|
class NodeEditor extends BuiltinFunctionObject {
|
||||||
|
|
||||||
NodeEditor (String name, Evaluator evaluator, FunctionPrototype fp) {
|
NodeEditor (String name, Evaluator evaluator, FunctionPrototype fp) {
|
||||||
|
@ -718,6 +737,7 @@ public final class HopExtension {
|
||||||
String tmpname = arguments.length == 0 ? "" : arguments[0].toString ();
|
String tmpname = arguments.length == 0 ? "" : arguments[0].toString ();
|
||||||
String basicHref =app.getNodeHref (elem, tmpname);
|
String basicHref =app.getNodeHref (elem, tmpname);
|
||||||
String hrefSkin = app.getProperty ("hrefSkin", null);
|
String hrefSkin = app.getProperty ("hrefSkin", null);
|
||||||
|
|
||||||
// FIXME: we should actually walk down the path from the object we called href() on
|
// FIXME: we should actually walk down the path from the object we called href() on
|
||||||
// instead we move down the URL path.
|
// instead we move down the URL path.
|
||||||
if (hrefSkin != null) {
|
if (hrefSkin != null) {
|
||||||
|
@ -725,10 +745,19 @@ public final class HopExtension {
|
||||||
// first, look in the object href was called on.
|
// first, look in the object href was called on.
|
||||||
Object skinElem = elem;
|
Object skinElem = elem;
|
||||||
Skin skin = null;
|
Skin skin = null;
|
||||||
|
// ResponseTrans res = fesi.getResponse();
|
||||||
|
// Object[] skinpath = res.getSkinpath ();
|
||||||
while (skin == null && skinElem != null) {
|
while (skin == null && skinElem != null) {
|
||||||
Prototype proto = app.getPrototype (skinElem);
|
Prototype proto = app.getPrototype (skinElem);
|
||||||
if (proto != null)
|
if (proto != null) {
|
||||||
skin = proto.getSkin (hrefSkin);
|
skin = proto.getSkin (hrefSkin);
|
||||||
|
/* String skinid = proto.getName()+"/"+hrefSkin;
|
||||||
|
skin = res.getCachedSkin (skinid);
|
||||||
|
if (skin == null) {
|
||||||
|
skin = app.getSkin (skinElem, hrefSkin, skinpath);
|
||||||
|
res.cacheSkin (skinid, skin);
|
||||||
|
} */
|
||||||
|
}
|
||||||
if (skin == null)
|
if (skin == null)
|
||||||
skinElem = app.getParentElement (skinElem);
|
skinElem = app.getParentElement (skinElem);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue