context in javascript action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2006 10:05 AM
http://forums.alfresco.com/viewtopic.php?t=3161&highlight=javascript
http://forums.alfresco.com/viewtopic.php?t=3775&highlight=javascript
I read the above posts and tried a lot but still cannot get parameters into my javascript and i don't know either how to return to my original page from my script.
in my web-client-config-custum.xml i have:
<config>
<actions>
<!– Launch Test Javascript Dialog –>
<action id="test_js">
<label>Test Javascript</label>
<image>/images/icons/add.gif</image>
<!– action>dialog:testJS</action –>
<!– action-listener>#{BrowseBean.setupContentAction}</action-listener –>
<script>/Company Home/Data Dictionary/Scripts/append testmessage.js%26dummy=dummy1</script>
<params>
<param name="id">#{actionContext.id}</param>
</params>
</action>
<!– Add action to more actions menu for each space –>
<action-group id="document_browse_menu">
<action idref="test_js" />
</action-group>
</actions>
</config>
I know that to get the context (eg. document and space) in a java action
you can reference your BrowseBean. when you have an action-handler with BrowseBean.setupContentAction.
But how can i use (reference) document and space in my javascript action?
How can i return to for example "/alfresco/faces/jsp/browse/browse.jsp" from my javascript action?
A third question i have is:
Where do the methods exist that are referenced in <config><action><onclick>?
Thank in advance for answering these question!
Kind regards,
Ronald Vermeire
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2006 08:50 AM
Anyone knows if this is documented in one of the wikis?
Kind regards,
Ronald Vermeire
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2006 05:36 AM
Just to stay on top a little. :mrgreen:
Anyone, or is the question not very clear or ……… ?
Kind regards,
Ronald Vermeire
Software Engineer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2006 07:59 AM
http://wiki.alfresco.com/wiki/Externalised_Client_Actions
Parameters for javascript actions and standard method based actions are this config block:
<params><param name="id">#{actionContext.id}</param><param name="dummy">dummy1</param></params>
So in this example the "id" arg will be set to the ID of the node the action is running on, and the "dummy" arg will be set to the value of "dummy1".Note that the args are made available in the 'args' object as name/value pairs as mentioned in the wiki docs.
Cheers,
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2006 10:37 AM
First of all thanks for the pointer to the Wiki. But i am still not there, still no
parameters in my script. I have done the following. I started of by adding a custom menu item and then i gave the menu something to call namely the script: myparams.js
I configured the following in web-client-config-custom.xml:
<config>
<actions>
<!– Launch js_test Dialog –>
<action id="js_test">
<label>Test javascript</label>
<image>/images/icons/add.gif</image>
<script>/Company Home/Data Dictionary/Scripts/myparams.js</script>
<params>
<param name="dummy">dummy1</param>
<param name="id">#{actionContext.id}</param>
</params>
</action>
<!– Add action to more actions menu for each document–>
<action-group id="document_browse_menu">
<action idref="js_test" />
</action-group>
</actions>
</config>
The myparams.js script looks like this:
logger.log("–>");
logger.log ("companyhome: " + companyhome)
var mydummy = args["dummy"];
var myid = args["id"];
logger.log("args[0] " + args[0] + " mydummy: " + mydummy + " myid : "+ myid);
logger.log("<–");
And the logger writes the following output:
16:28:39,781 DEBUG [repo.jscript.RhinoScriptService] Executing script: workspace
://SpacesStore/7cb09a38-6cc4-11db-93a1-a3f83372d0ec
16:28:39,796 DEBUG [repo.jscript.ScriptLogger] –>
16:28:39,796 DEBUG [repo.jscript.ScriptLogger] companyhome: Node Type: {http://w
ww.alfresco.org/model/content/1.0}folder
Node Properties: 12
Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www
.alfresco.org/model/application/1.0}uifacets, {http://www.alfresco.org/model/sys
tem/1.0}referenceable]
16:28:39,796 DEBUG [repo.jscript.ScriptLogger] args[0] /Company Home/Data Dictio
nary/Scripts/myparams.js mydummy: null myid : null
16:28:39,796 DEBUG [repo.jscript.ScriptLogger] <–
16:28:39,796 DEBUG [repo.jscript.RhinoScriptService] Time to execute script: 15ms
As you can see both dummy and id are null.
This is really all the configuration and code i customized in Alfresco.
What am i missing or doing wrong here?
Thanks in advance!
Kind regards,
Ronald Vermeire

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2006 12:05 PM
Thanks,
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2006 01:37 PM
http://forums.alfresco.com/viewtopic.php?t=3952
But no answers till now, so i am getting curious if this feature is really
available in the current release.
Kind regards,
Ronald Vermeire

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2006 05:14 AM
I'll take a look at this today, but i'm 99% sure it is working with basic types passed as parameters.
Thanks,
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2006 06:17 AM
I read the other post again and now it worked for him. When i saw your answer i tried some things and i now know what the problem is!
<action-group id="document_browse_menu">
<action idref="test_js" />
</action-group>
This one does not work
<action-group id="doc_details_actions">
<action idref="test_js" />
</action-group>
This one does not work
<action-group id="document_browse">
<action idref="test_js" />
</action-group>
This one does work
Is this all how it should work, or should i be able to get actionContext.id from document_browse_menu and doc_details_actions?
Kind regards,
Ronald Vermeire

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2006 06:23 AM
I'm not sure why it's not working for the script execution as other actions within the same actiongroups all access #{actionContext.id} with no problem - otherwise nothing in the app would be working!

Thanks,
Kevin
