Creating an ui action to launch a js script

Support questions about developing components for the Alfresco Explorer (JSF) Web Client

Creating an ui action to launch a js script

Postby vbaudry on 11 Sep 2006, 09:22

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 ?
vbaudry
Community Member
Community Member
 
Posts: 20
Joined: 05 Sep 2006, 15:04

1 Point (What's this)

Postby kevinr on 11 Sep 2006, 09:27

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:

Code: Select all
<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
Alfresco Applications Team Leader
http://twitter.com/kevinroast - Find me on Twitter
http://www.alfresco.com/community/register - Alfresco Manuals
http://wiki.alfresco.com - Alfresco Wiki docs
http://wiki.alfresco.com/wiki/Developer_Guide - Alfresco Developer Guide
kevinr
Alfresco Engineer
Alfresco Engineer
 
Posts: 2539
Joined: 27 Jun 2005, 15:56
Location: London
Alfresco Version: 3.2

14 Points (What's this)

Postby vbaudry on 11 Sep 2006, 09:51

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 :

// 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 ?
vbaudry
Community Member
Community Member
 
Posts: 20
Joined: 05 Sep 2006, 15:04

1 Point (What's this)

Postby vbaudry on 11 Sep 2006, 15:03

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 ?
vbaudry
Community Member
Community Member
 
Posts: 20
Joined: 05 Sep 2006, 15:04

1 Point (What's this)

Postby kevinr on 26 Sep 2006, 10:12

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/ ... browse.jsp

Thanks,

Kevin
Alfresco Applications Team Leader
http://twitter.com/kevinroast - Find me on Twitter
http://www.alfresco.com/community/register - Alfresco Manuals
http://wiki.alfresco.com - Alfresco Wiki docs
http://wiki.alfresco.com/wiki/Developer_Guide - Alfresco Developer Guide
kevinr
Alfresco Engineer
Alfresco Engineer
 
Posts: 2539
Joined: 27 Jun 2005, 15:56
Location: London
Alfresco Version: 3.2

14 Points (What's this)

document not defined

Postby calexo on 20 Oct 2006, 12:55

vbaudry wrote:// 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 ?

Hi !
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>
calexo
 
Posts: 1
Joined: 20 Oct 2006, 12:44

0 Points (What's this)

Postby kevinr on 23 Oct 2006, 16:24

That's a completely different issue. You cannot enter script into the <params> tag for the action definition. e.g. this is wrong:
Code: Select all
<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:
Code: Select all
<params>
<param name="id">#{actionContext.id}</param>
</params>


Thanks,

Kevin
Alfresco Applications Team Leader
http://twitter.com/kevinroast - Find me on Twitter
http://www.alfresco.com/community/register - Alfresco Manuals
http://wiki.alfresco.com - Alfresco Wiki docs
http://wiki.alfresco.com/wiki/Developer_Guide - Alfresco Developer Guide
kevinr
Alfresco Engineer
Alfresco Engineer
 
Posts: 2539
Joined: 27 Jun 2005, 15:56
Location: London
Alfresco Version: 3.2

14 Points (What's this)


Return to Alfresco Explorer Development

Who is online

Users browsing this forum: No registered users and 1 guest