v = reval.scriptingEngine.invoke (handlerObject, name+"_macro", arguments, false);
Object v = reval.scriptingEngine.invoke (handlerObject, name+"_macro", arguments, false);  if (reval.res.getBufferLength () > oldLength) {  if (prefix != null) reval.res.insert (oldLength, prefix); if (suffix != null) reval.res.write (suffix); writeToResponse (v, reval.res, false); } else { writeToResponse (v, reval.res, true); }
	public void render (RequestEvaluator reval, Object thisObject, HashMap paramObject) throws RedirectException {	    if (sandbox != null && !sandbox.contains (getFullName ())) {	        String h = handler == null ? "global" : handler;	        reval.res.write ("[Macro "+getFullName()+" not allowed in sandbox]");	        return;	    } else if ("response".equalsIgnoreCase (handler)) {	        renderFromResponse (reval);	        return;	    } else if ("request".equalsIgnoreCase (handler)) {	        renderFromRequest (reval);	        return;	    } else if ("param".equalsIgnoreCase (handler)) {	        renderFromParam (reval, paramObject);	        return;	    }	    try {	        Object handlerObject = null;	        Object[] arguments = new Object[1];	        // pass a clone of the parameter map so if the script changes it,	        // we still keep the original version.	        arguments[0] = parameters.clone ();	        // flag to tell whether we found our invocation target object	        boolean objectFound = true;	        if (handler != null) {	            if (thisObject != null) {	                // not a global macro - need to find handler object	                // was called with this object - check it or its parents for matching prototype	                if (!handler.equalsIgnoreCase ("this") && !handler.equalsIgnoreCase (app.getPrototypeName (thisObject))) {	                    // the handler object is not what we want	                    Object n = thisObject;	                    // walk down parent chain to find handler object	                    while (n != null) {	                        if (handler.equalsIgnoreCase (app.getPrototypeName (n))) {	                            handlerObject = n;	                            break;	                        }	                        n = app.getParentElement (n);	                    }	                } else {	                    // we already have the right handler object	                    handlerObject = thisObject;	                }	            }	            if (handlerObject == null) {	                // eiter because thisObject == null or the right object wasn't found in the object's parent path	                // go check request path for an object with matching prototype	                int l = reval.requestPath.size();	                for (int i=l-1; i>=0; i--) {	                    Object pathelem = reval.requestPath.get (i);	                    if (handler.equalsIgnoreCase (app.getPrototypeName (pathelem))) {	                         handlerObject = pathelem;	                         break;	                    }	                }	            }	            // the macro handler object couldn't be found	            if (handlerObject == null)	                objectFound = false;	        } else {	            // this is a global macro with no handler specified	            handlerObject = null;	        }	        if (objectFound) {	            // check if a function called name_macro is defined.	            // if so, the macro evaluates to the function. Otherwise,	            // a property/field with the name is used, if defined.	            Object v = null;	            // remember length of response buffer before calling macro	            int oldLength = reval.res.getBufferLength ();	            if (reval.scriptingEngine.hasFunction (handlerObject, name+"_macro")) {	                // System.err.println ("Getting macro from function");	                v = reval.scriptingEngine.invoke (handlerObject, name+"_macro", arguments, false);	            } else {	                // System.err.println ("Getting macro from property");	                v = reval.scriptingEngine.get (handlerObject, name);	            }	            // check if macro wrote out to response buffer	            if (reval.res.getBufferLength () > oldLength) {	               // insert prefix and append suffix	               String prefix = (String) parameters.get ("prefix");	               String suffix = (String) parameters.get ("suffix");	               if (prefix != null)	                   reval.res.insert (oldLength, prefix);	               if (suffix != null)	                   reval.res.write (suffix);	            }	            // if macro returned something append it to response	            if (v != null) {	                writeToResponse (v.toString (), reval.res);	            }	            // if the macro hasn't produced any output, write default attribute	            // if it is specified.	            if (reval.res.getBufferLength () == oldLength) {	               String defaultValue = (String) parameters.get ("default");	               if (defaultValue != null)	                   reval.res.write (defaultValue);	            }	        } else {	            String msg = "[HopMacro unhandled: "+getFullName()+"]";	            reval.res.write (" "+msg+" ");	            app.logEvent (msg);	        }	    } catch (RedirectException redir) {	        throw redir;	    } catch (ConcurrencyException concur) {	        throw concur;	    } catch (TimeoutException timeout) {	        throw timeout;	    } catch (Exception x) {	        x.printStackTrace();	        String msg = "[HopMacro error in "+getFullName()+": "+x+"]";	        reval.res.write (" "+msg+" ");	        app.logEvent (msg);	    }	}