context in javascript action
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2006 10:05 AM
Hello,
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
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:
- Labels:
-
Archive
16 REPLIES 16
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2006 07:42 AM
Hello,
In this post:
http://forums.alfresco.com/viewtopic.php?t=3952
Mitesh Panchal has the following code to get the current Node.
He asks if there is alternative way to find that node and i have exactly the same question. Because with hundred thousands nodes in the repository in different spaces it could take a long time before finding the correct node. So my question is, is there an alternative way?
Kind regards,
Ronald Vermeire
In this post:
http://forums.alfresco.com/viewtopic.php?t=3952
Mitesh Panchal has the following code to get the current Node.
var curForum;forums = companyhome.childByNamePath("Forums");logger.log(forums.name);forumsChildren =forums.children;for(i=0;i<forumsChildren .length;i++){ child =forumsChildren[i]; if(child.id.equals(args["id"])) { curForum = child; logger.log("Current Forum Name : " + curForum .name); }}
He asks if there is alternative way to find that node and i have exactly the same question. Because with hundred thousands nodes in the repository in different spaces it could take a long time before finding the correct node. So my question is, is there an alternative way?
Kind regards,
Ronald Vermeire

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2006 09:46 AM
Depends what you mean by "current" - I also said this in that forum thread:
So SpaceDetailsBean.space.id will return the ID of the node for the current space if you are in the Space Details screen, and NavigationBean.currentNodeId will return the ID of the node for the current space if you are browsing around.
Thanks,
Kevin
you can pass the ID for the space e.g. SpaceDetailsBean.space.id should work ok. Of course SpaceDetailsBean.space.id is only valid when in the context of the Space Details dialog page. Generally the "current" space can be found using:
NavigationBean.currentNodeId
So SpaceDetailsBean.space.id will return the ID of the node for the current space if you are in the Space Details screen, and NavigationBean.currentNodeId will return the ID of the node for the current space if you are browsing around.
Thanks,
Kevin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2006 09:56 AM
Hello,
My question realy is how do i get a 'document' Node object from the simple type actionContext.id or the 'space' Node object from the simple type SpaceDetailsBean.space.id. I already tried NavigationBean.currentNode.path and then in my script companyhome.childByNamePath but that didn't work.
Kind regards,
Ronald Vermeire
My question realy is how do i get a 'document' Node object from the simple type actionContext.id or the 'space' Node object from the simple type SpaceDetailsBean.space.id. I already tried NavigationBean.currentNode.path and then in my script companyhome.childByNamePath but that didn't work.
Kind regards,
Ronald Vermeire
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2006 04:04 PM
Hello,
I finally managed it by using:
But this took 12125 ms which i found quit long
, isn't there an alternative ?
The most logical to me would be a method like getNode(nodeId) .
What are your thoughts?
Kind regards,
Ronald Vermeire
I finally managed it by using:
companyhome.childrenByXPath("//*[@cm:name='"+ myNodename + "']")
But this took 12125 ms which i found quit long

The most logical to me would be a method like getNode(nodeId) .
What are your thoughts?
Kind regards,
Ronald Vermeire

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2006 04:13 AM
This is a little embarrassing - as there is already a method to help you do exactly that but I had forgotten to document it :roll:
I've added the documentation for the search.findNode(ref) method which you can easily use to find a node by ID:
http://wiki.alfresco.com/wiki/JavaScript_API#Search_API
Example:
Thanks,
Kevin
I've added the documentation for the search.findNode(ref) method which you can easily use to find a node by ID:
http://wiki.alfresco.com/wiki/JavaScript_API#Search_API
Example:
var id = args["id"]; // assume the 'id' arg contains a node idvar node = search.findNode("workspace://SpacesStore/" + id);if (node != null){ // we found the node…}
Thanks,
Kevin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2006 04:21 AM
Hello Kevin,
This is the method i was realy looking for!:wink: Thanks for your actions and answers in this thread.
Kind regards,
Ronald Vermeire
This is the method i was realy looking for!:wink: Thanks for your actions and answers in this thread.
Kind regards,
Ronald Vermeire

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2007 07:36 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?
This bug has now been identified and fixed for the next enterprise/community release.
http://issues.alfresco.com/browse/AWC-1065
Thanks,
Kevin
