1 16 package org.apache.cocoon.forms.flow.javascript; 17 18 import org.mozilla.javascript.ScriptableObject; 19 import org.mozilla.javascript.Undefined; 20 import org.mozilla.javascript.Wrapper; 21 import org.mozilla.javascript.continuations.Continuation; 22 import org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon; 23 import org.apache.cocoon.components.flow.javascript.fom.FOM_WebContinuation; 24 import org.apache.cocoon.environment.Request; 25 26 30 public class Form extends ScriptableObject { 31 FOM_Cocoon cocoon; 32 33 public String getClassName() { 34 return "Form"; 35 } 36 37 private FOM_Cocoon getCocoon() { 38 if (cocoon == null) { 39 cocoon = (FOM_Cocoon)getProperty(getTopLevelScope(this), "cocoon"); 40 } 41 return cocoon; 42 } 43 44 public FOM_WebContinuation jsFunction_makeWebContinuation(Object k, 45 Object lastContinuation, 46 int ttl) 47 throws Exception { 48 Continuation kont = (Continuation)unwrap(k); 49 FOM_WebContinuation fom_wk = 50 (FOM_WebContinuation)unwrap(lastContinuation); 51 FOM_Cocoon cocoon = getCocoon(); 52 return cocoon.makeWebContinuation(kont, fom_wk, ttl); 53 } 54 55 public void jsFunction_forwardTo(String uri, 56 Object bizData, 57 Object continuation) 58 throws Exception { 59 FOM_Cocoon cocoon = getCocoon(); 60 FOM_WebContinuation fom_wk = 61 (FOM_WebContinuation)unwrap(continuation); 62 cocoon.forwardTo(uri, 63 unwrap(bizData), 64 fom_wk); 65 66 } 67 68 public Request jsGet_request() { 69 FOM_Cocoon cocoon = getCocoon(); 70 return cocoon.getRequest(); 71 } 72 73 private Object unwrap(Object obj) { 74 if (obj == Undefined.instance) { 75 return null; 76 } 77 if (obj instanceof Wrapper) { 78 return ((Wrapper)obj).unwrap(); 79 } 80 return obj; 81 } 82 } 83 | Popular Tags |