peter royal <[EMAIL PROTECTED]> writes:

> Sent: Friday, January 02, 2004 11:08 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Accessing flow context attributes
> 
> 
> 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.ScriptablePropert
> yHandler 
> (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
> 

Makes sense, I suspected FlowHelper as the target spot for this.  I
might be able to get around to this in a couple of months from now
(sigh) if no one beats me to it...

Reply via email to