Creating an ui action to launch a js script

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 05:22 AM
Hello !
I would like to create an ui action tu launch a determined js script.
Does anyone know how I can do that quite simply ?
I've seen how to create a custom ui button, but how can I do a really simple actionlistener that only launch the script ?
I would like to create an ui action tu launch a determined js script.
Does anyone know how I can do that quite simply ?
I've seen how to create a custom ui button, but how can I do a really simple actionlistener that only launch the script ?
Labels:
- Labels:
-
Archive
6 REPLIES 6

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 05:27 AM
We have added support for this in 1.4, you can now specify a script directly in the XML definition for an action. In your override file for the action definition XML, you just need a line like this as part of your action definition:
You can also specify the full NodeRef to the script, but the path is normally easier.
Thanks,
Kevin
<script>/Company Home/Data Dictionary/Scripts/myjavascript.js</script>
You can also specify the full NodeRef to the script, but the path is normally easier.
Thanks,
Kevin

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 05:51 AM
Thanks a lot ! I tested it in 1.4 preview and it seems to work.
But I've a little problem with de javascript.
My file is really simple, it looks like this :
But when I run my action, an error says that "space" is not defined.
Any idea ?
But I've a little problem with de javascript.
My file is really simple, it looks like this :
// modify the parent space name
space.name = space.name + " 1";
space.save();
But when I run my action, an error says that "space" is not defined.
Any idea ?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 11:03 AM
Got another point.
When I execute the script, it runs in the window and replaces alfresco. Is it possible to come back to alfresco after the script has run ?
When I execute the script, it runs in the window and replaces alfresco. Is it possible to come back to alfresco after the script has run ?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2006 06:12 AM
Yes the script command servlet excepts a URL parameter called "return-page" that defines the return page URL e.g.
http://localhost:8080/alfresco/command/script/execute?scriptPath=/Company%20Home/Data%20Dictionary/S...
Thanks,
Kevin
http://localhost:8080/alfresco/command/script/execute?scriptPath=/Company%20Home/Data%20Dictionary/S...
Thanks,
Kevin
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2006 08:55 AM
// modify the parent space nameHi !
space.name = space.name + " 1";
space.save();But when I run my action, an error says that "space" is not defined.
Any idea ?
I'm having the same problem, while using a JS script to change a document property : it says document is unknown…
Here is the action, as I defined :
<action id="payer">
<label>Payer</label>
<image>/images/icons/add.gif</image>
<label>Payer</label>
<script>/Company Home/Data Dictionary/Scripts/PayerFacture.js</script>
<params>
<param name="id">#{document.id}</param>
</params>
</action>

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2006 12:24 PM
That's a completely different issue. You cannot enter script into the <params> tag for the action definition. e.g. this is wrong:
All that section does is pass URL parameters to your script as specified in the <script> element.
The params section should read:
Thanks,
Kevin
<params><param name="id">#{document.id}</param></params>
All that section does is pass URL parameters to your script as specified in the <script> element.
The params section should read:
<params><param name="id">#{actionContext.id}</param></params>
Thanks,
Kevin
