From 80a4e366c34b770850822d4a324d8d7551124646 Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 10 Aug 2001 18:11:59 +0000 Subject: [PATCH] Fixed getSkin to actually walk down prototype path res.skin can now be set to other than global skins, using "prototype.skin" syntax. This is resolved against the request path. --- .../framework/core/RequestEvaluator.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/helma/framework/core/RequestEvaluator.java b/src/helma/framework/core/RequestEvaluator.java index 13e0b50a..a5dcebd9 100644 --- a/src/helma/framework/core/RequestEvaluator.java +++ b/src/helma/framework/core/RequestEvaluator.java @@ -203,6 +203,8 @@ public class RequestEvaluator implements Runnable { Prototype p = app.getPrototype (root); String errorAction = app.props.getProperty ("error", "error"); action = p.getActionOrTemplate (errorAction); + if (action == null) + throw new RuntimeException (error); } else if (req.path == null || "".equals (req.path.trim ())) { currentNode = root; @@ -333,11 +335,26 @@ public class RequestEvaluator implements Runnable { try { localrtx.timer.beginEvent (requestPath+" execute"); current.doIndirectCall (evaluator, current, action.getFunctionName (), new ESValue[0]); + + // check if the script set the name of a skin to render in res.skin if (res.skin != null) { - Skin skin = getSkin (null, res.skin); + int dot = res.skin.indexOf ("."); + ESValue sobj = null; + String sname = res.skin; + if (dot > -1) { + String soname = res.skin.substring (0, dot); + sobj = reqPath.getProperty (soname, soname.hashCode ()); + if (sobj == null || sobj == ESUndefined.theUndefined) + throw new RuntimeException ("Skin "+res.skin+" not found in path."); + sname = res.skin.substring (dot+1); + } + Skin skin = getSkin ((ESNode) sobj, sname); if (skin != null) - skin.render (this, null, null); + skin.render (this, (ESNode) sobj, null); + else + throw new RuntimeException ("Skin "+res.skin+" not found in path."); } + localrtx.timer.endEvent (requestPath+" execute"); } catch (RedirectException redirect) { // res.redirect = redirect.getMessage (); @@ -852,11 +869,11 @@ public class RequestEvaluator implements Runnable { } public ObjectPrototype getPrototype (String protoName) { - return (ObjectPrototype) prototypes.get (protoName); + return (ObjectPrototype) prototypes.get (protoName.toLowerCase ()); } public void putPrototype (String protoName, ObjectPrototype op) { - prototypes.put (protoName, op); + prototypes.put (protoName.toLowerCase (), op); }