cancel
Showing results for 
Search instead for 
Did you mean: 

a problem with javascript

donnie
Champ in-the-making
Champ in-the-making
Hello ,im a begginer in alfresco 3.2r ,my task is to creat a content rule over a space , when i add a new document into the space
,a script(javascript) must be executed ,this JS must call a web application (either applet ,jsp or servlet) that handle a java class managing research over the document added into the space ..

i already created a applet for my java class ,but the problem ,is ,i don't know how to communicate with alfresco

in first place a tried to use a simple JS that open an simple html page  :

i put in Company Home\Data Dictionary\Scripts this Javascript :

<HTML> 
<HEAD>
<TITLE>JavaScript</TITLE>
</HEAD>
<BODY>
<P> hey.</P>
<SCRIPT LANGUAGE="JavaScript">
  window.document.write('<P><B>hey ++</B></P>');
</SCRIPT>
 
</BODY>
</HTML>


but nothing happens ,is there a problem with <HTML>  <HEAD> ??  what should i do ??
ps sorry for my bad english
3 REPLIES 3

jpotts
World-Class Innovator
World-Class Innovator
It sounds like you are writing a rule action that triggers some JavaScript. That JavaScript needs to invoke a service (a servlet) running elsewhere.

JavaScript that runs on the Alfresco server from the Scripts directory is server-side JavaScript. The sample you pasted in looks like client-side JavaScript (I see HTML tags and a window.document.write call).

You should look at the other scripts in the Scripts directory as well as the JavaScript API page on the wiki (http://wiki.alfresco.com/wiki/JavaScript_API) for examples of what's possible.

In your case, you need to open a connection over the network to invoke a service running somewhere else. For that, I think your best bet is to forget JavaScript and instead use a Java-based Action Executor that does this using standard HTTP commons libraries. See http://ecmarchitect.com/images/articles/alfresco-actions/actions-article.pdf for a tutorial on writing custom Java actions.

Jeff

donnie
Champ in-the-making
Champ in-the-making
jeff ,thanks for the replay ,i will try this ,and im gonna let u know

mourougan
Champ in-the-making
Champ in-the-making
Hi,

Have you find the solution to call external Servlet service from Alfresco scripts (either server side javascript or using custom actions?) ?

Please share if you have relevant info, I'm looking for a similar solution.

Thanks & regards,
Mourougan