ovidiu 2003/01/08 19:49:57
Modified: src/java/org/apache/cocoon/components/flow/javascript
JSCocoon.java
Log:
Fixed indentation.
Revision Changes Path
1.12 +116 -92
xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSCocoon.java
Index: JSCocoon.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JSCocoon.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- JSCocoon.java 9 Jan 2003 03:45:17 -0000 1.11
+++ JSCocoon.java 9 Jan 2003 03:49:57 -0000 1.12
@@ -282,97 +282,121 @@
return obj;
}
- public Scriptable jsFunction_callAction(String type, String source, Scriptable
parameters) throws Exception {
-
- Redirector redirector = new SitemapRedirector(this.environment);
- SourceResolver resolver = (SourceResolver)
this.environment.getObjectModel().get(JSCocoon.OBJECT_SOURCE_RESOLVER);
- ComponentManager sitemapManager = this.environment.getComponentManager();
- ComponentSelector actionSelector = (ComponentSelector)
sitemapManager.lookup(Action.ROLE+"Selector");
- Action action = (Action) actionSelector.select(type);
- Map result = null;
- try {
- result = action.act(redirector,
- resolver,
- this.environment.getObjectModel(),
- source,
- JSCocoon.jsobjectToParameters(parameters));
- } finally {
- actionSelector.release(action);
- }
-
- // what should be done with the redirector ??
- // ignore it or call sendPage with it?
- return (result!=null? new ScriptableMap(result) : null);
- }
-
-
- public static Parameters jsobjectToParameters(Scriptable jsobject){
- Parameters params = new Parameters();
- Object[] ids = jsobject.getIds();
- for (int i = 0; i < ids.length; i++) {
- String key = ScriptRuntime.toString(ids[i]);
- Object value = jsobject.get(key, jsobject);
- if (value == Undefined.instance)
- value = null;
- else
- value = ScriptRuntime.toString(value);
- params.setParameter(key, (String) value);
- }
- return params;
- }
-
- public Object jsFunction_inputModuleGetAttribute(String type, String attribute)
throws Exception {
- // since no new components can be declared on sitemap we could
- // very well use the 'other' one here. Anyway, since it's there...
- ComponentManager sitemapManager = this.environment.getComponentManager();
- ComponentSelector inputSelector = (ComponentSelector)
sitemapManager.lookup(InputModule.ROLE+"Selector");
- InputModule input = (InputModule) inputSelector.select(type);
- Object result = null;
- try {
- result = input.getAttribute(attribute, null,
this.environment.getObjectModel());
- } finally {
- inputSelector.release(input);
- }
- return result;
- }
-
- public void jsFunction_outputModuleSetAttribute(String type, String attribute,
Object value) throws Exception {
- // since no new components can be declared on sitemap we could
- // very well use the 'other' one here. Anyway, since it's there...
- ComponentManager sitemapManager = this.environment.getComponentManager();
- ComponentSelector outputSelector = (ComponentSelector)
sitemapManager.lookup(OutputModule.ROLE+"Selector");
- OutputModule output = (OutputModule) outputSelector.select(type);
- try {
- output.setAttribute(null, this.environment.getObjectModel(), attribute,
JSCocoon.jsobjectToObject(value));
- } finally {
- outputSelector.release(output);
- }
- }
-
- public void jsFunction_outputModuleCommit(String type) throws Exception {
- // since no new components can be declared on sitemap we could
- // very well use the 'other' one here. Anyway, since it's there...
- ComponentManager sitemapManager = this.environment.getComponentManager();
- ComponentSelector outputSelector = (ComponentSelector)
sitemapManager.lookup(OutputModule.ROLE+"Selector");
- OutputModule output = (OutputModule) outputSelector.select(type);
- try {
- output.commit(null, this.environment.getObjectModel());
- } finally {
- outputSelector.release(output);
- }
- }
-
- public void jsFunction_outputModuleRollback(String type) throws Exception {
- // since no new components can be declared on sitemap we could
- // very well use the 'other' one here. Anyway, since it's there...
- ComponentManager sitemapManager = this.environment.getComponentManager();
- ComponentSelector outputSelector = (ComponentSelector)
sitemapManager.lookup(OutputModule.ROLE+"Selector");
- OutputModule output = (OutputModule) outputSelector.select(type);
- try {
- output.rollback(null, this.environment.getObjectModel(), null);
- } finally {
- outputSelector.release(output);
- }
+ public Scriptable jsFunction_callAction(String type,
+ String source,
+ Scriptable parameters)
+ throws Exception
+ {
+ Redirector redirector = new SitemapRedirector(this.environment);
+ SourceResolver resolver = (SourceResolver)this.environment.getObjectModel()
+ .get(JSCocoon.OBJECT_SOURCE_RESOLVER);
+ ComponentManager sitemapManager = this.environment.getComponentManager();
+ ComponentSelector actionSelector
+ = (ComponentSelector)sitemapManager.lookup(Action.ROLE + "Selector");
+ Action action = (Action)actionSelector.select(type);
+ Map result = null;
+ try {
+ result = action.act(redirector,
+ resolver,
+ this.environment.getObjectModel(),
+ source,
+ JSCocoon.jsobjectToParameters(parameters));
+ }
+ finally {
+ actionSelector.release(action);
+ }
+
+ // what should be done with the redirector ??
+ // ignore it or call sendPage with it?
+ return (result!=null? new ScriptableMap(result) : null);
+ }
+
+ public static Parameters jsobjectToParameters(Scriptable jsobject)
+ {
+ Parameters params = new Parameters();
+ Object[] ids = jsobject.getIds();
+ for (int i = 0; i < ids.length; i++) {
+ String key = ScriptRuntime.toString(ids[i]);
+ Object value = jsobject.get(key, jsobject);
+ if (value == Undefined.instance)
+ value = null;
+ else
+ value = ScriptRuntime.toString(value);
+ params.setParameter(key, (String) value);
+ }
+ return params;
+ }
+
+ public Object jsFunction_inputModuleGetAttribute(String type, String attribute)
+ throws Exception
+ {
+ // since no new components can be declared on sitemap we could
+ // very well use the 'other' one here. Anyway, since it's there...
+ ComponentManager sitemapManager = this.environment.getComponentManager();
+ ComponentSelector inputSelector = (ComponentSelector)sitemapManager
+ .lookup(InputModule.ROLE + "Selector");
+ InputModule input = (InputModule) inputSelector.select(type);
+ Object result = null;
+ try {
+ result = input.getAttribute(attribute, null,
+ this.environment.getObjectModel());
+ }
+ finally {
+ inputSelector.release(input);
+ }
+ return result;
+ }
+
+ public void jsFunction_outputModuleSetAttribute(String type, String attribute,
+ Object value)
+ throws Exception
+ {
+ // since no new components can be declared on sitemap we could
+ // very well use the 'other' one here. Anyway, since it's there...
+ ComponentManager sitemapManager = this.environment.getComponentManager();
+ ComponentSelector outputSelector = (ComponentSelector)sitemapManager
+ .lookup(OutputModule.ROLE + "Selector");
+ OutputModule output = (OutputModule) outputSelector.select(type);
+ try {
+ output.setAttribute(null, this.environment.getObjectModel(), attribute,
+ JSCocoon.jsobjectToObject(value));
+ }
+ finally {
+ outputSelector.release(output);
+ }
+ }
+
+ public void jsFunction_outputModuleCommit(String type)
+ throws Exception
+ {
+ // since no new components can be declared on sitemap we could
+ // very well use the 'other' one here. Anyway, since it's there...
+ ComponentManager sitemapManager = this.environment.getComponentManager();
+ ComponentSelector outputSelector = (ComponentSelector)sitemapManager
+ .lookup(OutputModule.ROLE + "Selector");
+ OutputModule output = (OutputModule) outputSelector.select(type);
+ try {
+ output.commit(null, this.environment.getObjectModel());
+ }
+ finally {
+ outputSelector.release(output);
+ }
+ }
+
+ public void jsFunction_outputModuleRollback(String type)
+ throws Exception
+ {
+ // since no new components can be declared on sitemap we could
+ // very well use the 'other' one here. Anyway, since it's there...
+ ComponentManager sitemapManager = this.environment.getComponentManager();
+ ComponentSelector outputSelector = (ComponentSelector)sitemapManager
+ .lookup(OutputModule.ROLE + "Selector");
+ OutputModule output = (OutputModule) outputSelector.select(type);
+ try {
+ output.rollback(null, this.environment.getObjectModel(), null);
+ }
+ finally {
+ outputSelector.release(output);
+ }
}
-
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]