Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 11274 invoked from network); 3 Jan 2004 05:08:33 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 3 Jan 2004 05:08:33 -0000 Received: (qmail 88931 invoked by uid 500); 3 Jan 2004 05:08:10 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 88803 invoked by uid 500); 3 Jan 2004 05:08:09 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@cocoon.apache.org Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 88786 invoked from network); 3 Jan 2004 05:08:09 -0000 Received: from unknown (HELO wahoo.pace2020.com) (65.196.130.133) by daedalus.apache.org with SMTP; 3 Jan 2004 05:08:09 -0000 Received: from meatloaf.fotap.org ([66.93.248.91] helo=[192.168.1.4]) by wahoo.pace2020.com with asmtp (Exim 3.35 #1 (Debian)) id 1Ace1K-0000qA-00 for ; Sat, 03 Jan 2004 00:08:19 -0500 Mime-Version: 1.0 (Apple Message framework v609) In-Reply-To: <1E0CC447E59C974CA5C7160D2A2854EC02FECBEB@SJMEMXMB04.stjude.sjcrh.local> References: <1E0CC447E59C974CA5C7160D2A2854EC02FECBEB@SJMEMXMB04.stjude.sjcrh.local> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: peter royal Subject: Re: Accessing flow context attributes Date: Sat, 3 Jan 2004 00:08:17 -0500 To: dev@cocoon.apache.org X-Mailer: Apple Mail (2.609) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Jan 2, 2004, at 6:08 PM, Hunsberger, Peter wrote: > show and makes perfect sense in the flow script. So I coded a flow > script with statements like: > > cocoon.sendPage( "run/_page/" + collection, { > "layout_type_preference" : "list" } ); > It seems to me that this really needs to be refactored into some helper > class, though I'm not sure where? If you follow the rabbit hole a bit more, you'll find the real secret which is in org.apache.cocoon.components.flow.javascript.ScriptablePropertyHandler (initialized in JavaScriptInterpreter) and the essence of which can be boiled down to: final Object o = unwrap( FlowHelper.getContextObject( objectModel ) ); if( o instanceof Scriptable ) { final Scriptable jsobject = (Scriptable)o; final Object[] ids = jsobject.getIds(); for( int i = 0; i < ids.length; i++ ) { final String key = ScriptRuntime.toString( ids[i] ); final Object value = jsobject.get( key, jsobject ); //do something with the key and value now. } } So the 'utility' could be a FlowHelper.getContextObjectAsMap or such.. -pete