AlfrescoJavaScript: global script variables
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 06:06 AM
Good day everyone!
I have been reading Alfresco's source code for some time, till I got to the createInputMap method in AlfrescoJavaScript.java file.
Inside that method I read that global variables like userhome and person are mapped into a Java HashMap, so that they're disposable for all scripts (depending on context).
Is there a way to have more global variables without modifying that file? Something like mycompanyhome or companyhomeRome, companyhomeFlorence and so on…
Thanks in advance
I have been reading Alfresco's source code for some time, till I got to the createInputMap method in AlfrescoJavaScript.java file.
Inside that method I read that global variables like userhome and person are mapped into a Java HashMap, so that they're disposable for all scripts (depending on context).
Is there a way to have more global variables without modifying that file? Something like mycompanyhome or companyhomeRome, companyhomeFlorence and so on…
Thanks in advance

Labels:
- Labels:
-
Archive
4 REPLIES 4

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 06:08 AM
Yes.
Take a look at script-services-context.xml.
It demonstrates how to inject new root variables into script.
Take a look at script-services-context.xml.
It demonstrates how to inject new root variables into script.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 06:14 AM
lol, flashreply ftw!
Thanks man
Thanks man

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 10:27 AM
I have another question about search APIs: can you tell me examples of XPatch search (by using xpathSearch(String search)), Lucene search (by using luceneSearch(String search)) and normal search (by using findNode(String ref)) to find an hypothetical "Test Space", son of the default space "Company Home"?
I have to get that noderef in order to build a folder tree inside it.
Thanks
I have to get that noderef in order to build a folder tree inside it.
Thanks
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2007 08:31 AM
I tried this script:
I used the noderef taken from the properties of the folder.
var testFolder = search.findNode("workspace://SpacesStore/c88cbacf-b208-11db-b111-6108c46f71e5");var prjFolder = testFolder.createFolder("Folder di Prova");prjFolder = prjFolder.childByNamePath("Folder di Prova");prjFolder.createFolder("Documenti di gara");prjFolder.createfolder("Offerta tecnico economica");
But is not working:14:22:04,170 ERROR [org.alfresco.web.ui.common.Utils] A system error happened during the operation: Failed to signal transition '' from workflow task 'jbpm$19'org.alfresco.service.cmr.workflow.WorkflowException: Failed to signal transition '' from workflow task 'jbpm$19' at org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:1077) at org.alfresco.repo.workflow.WorkflowServiceImpl.endTask(WorkflowServiceImpl.java:322) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:116) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:32) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:41) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:211) at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:157) at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:61) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176) at $Proxy24.endTask(Unknown Source) at org.alfresco.web.bean.workflow.ManageTaskDialog.transition(ManageTaskDialog.java:292) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63) at javax.faces.component.UICommand.broadcast(UICommand.java:106) at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164) at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:105) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:73) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595)Caused by: org.jbpm.graph.def.DelegationException at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:352) at org.jbpm.graph.def.GraphElement.raiseException(GraphElement.java:346) at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:249) at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:212) at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:182) at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:166) at org.jbpm.graph.def.Transition.take(Transition.java:106) at org.jbpm.graph.def.Node.leave(Node.java:383) at org.jbpm.graph.exe.ExecutionContext.leaveNode(ExecutionContext.java:136) at org.jbpm.graph.node.Decision.execute(Decision.java:146) at org.jbpm.graph.def.Node.enter(Node.java:316) at org.jbpm.graph.def.Node$$FastClassByCGLIB$$d187eeda.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:163) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161) at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$6ecc8b64.enter(<generated>) at org.jbpm.graph.def.Transition.take(Transition.java:119) at org.jbpm.graph.def.Node.leave(Node.java:383) at org.jbpm.graph.node.TaskNode.leave(TaskNode.java:198) at org.jbpm.graph.node.TaskNode$$FastClassByCGLIB$$923668a4.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:163) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161) at org.jbpm.graph.node.TaskNode$$EnhancerByCGLIB$$a91281ae.leave(<generated>) at org.jbpm.graph.exe.Token.signal(Token.java:174) at org.jbpm.graph.exe.Token.signal(Token.java:145) at org.jbpm.graph.exe.Token$$FastClassByCGLIB$$74df1c6e.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:163) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161) at org.jbpm.graph.exe.Token$$EnhancerByCGLIB$$1b5b31f8.signal(<generated>) at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:444) at org.alfresco.repo.workflow.jbpm.WorkflowTaskInstance.end(WorkflowTaskInstance.java:118) at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:383) at org.alfresco.repo.workflow.jbpm.JBPMEngine$19.doInJbpm(JBPMEngine.java:1062) at org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTemplate.java:87) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:333) at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:80) at org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:1030) … 52 moreCaused by: org.alfresco.service.cmr.repository.ScriptException: Failed to execute supplied script: TypeError: Cannot call method "createFolder" of null (AlfrescoScript#1) at org.alfresco.repo.jscript.RhinoScriptService.executeScriptString(RhinoScriptService.java:227) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:116) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:32) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:41) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:196) at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:61) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176) at $Proxy56.executeScriptString(Unknown Source) at org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript.executeScript(AlfrescoJavaScript.java:144) at org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript.execute(AlfrescoJavaScript.java:118) at org.jbpm.graph.def.Action.execute(Action.java:123) at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:235) … 86 moreCaused by: org.alfresco.error.AlfrescoRuntimeException: TypeError: Cannot call method "createFolder" of null (AlfrescoScript#1) at org.alfresco.repo.jscript.RhinoScriptService.executeScriptImpl(RhinoScriptService.java:303) at org.alfresco.repo.jscript.RhinoScriptService.executeScriptString(RhinoScriptService.java:223) … 110 moreCaused by: org.mozilla.javascript.EcmaError: TypeError: Cannot call method "createFolder" of null (AlfrescoScript#1) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3226) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3216) at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3232) at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3251) at org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3270) at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:1966) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2931) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755) at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:160) at org.mozilla.javascript.Context.evaluateReader(Context.java:1163) at org.alfresco.repo.jscript.RhinoScriptService.executeScriptImpl(RhinoScriptService.java:291) … 111 more
I used the noderef taken from the properties of the folder.
