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



Reply via email to