execute javascript directly on JSP

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 05:26 AM
Hi,
I try this, to get the person first name, in javascript …
var name = person.properties.FirstName;
document.write(name);
but the variavle person is not defined….
ops:
can someone give me a litle help here….
thanks very much!
I try this, to get the person first name, in javascript …
var name = person.properties.FirstName;
document.write(name);
but the variavle person is not defined….

can someone give me a litle help here….
thanks very much!
Labels:
- Labels:
-
Archive
4 REPLIES 4

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 08:26 AM
There are two things wrong with your script, firstly JavaScript and the Alfresco JavaScript API are case sensitive - so the property name is wrong, you need:
var name = person.properties.firstName;
also the document.write(…) will not work - the document.write() function is part of the web browser JavaScript extensions - the Alfresco javascript engine is pure JavaScript 1.6 with our Alfresco extensions.
Hope this helps,
Kevin
var name = person.properties.firstName;
also the document.write(…) will not work - the document.write() function is part of the web browser JavaScript extensions - the Alfresco javascript engine is pure JavaScript 1.6 with our Alfresco extensions.
Hope this helps,
Kevin

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 08:35 AM
…I've just read the title of your post
You can't execute Alfresco JavaScript within a JSP and expect it to work…! As i said earlier - the browser JavaScript API is very different to ours.
Kevin

Kevin

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2007 09:58 AM
Sorry if i ask dumb questions… but can you tell me where i can get more information how to use javascript in alfresco?
i already read the java script api, but i dont andertand very well this question…
i have to execute something before i can execute this? I can´t put this code directly in JSP files?
thanks….
i already read the java script api, but i dont andertand very well this question…
i have to execute something before i can execute this? I can´t put this code directly in JSP files?
thanks….

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2007 04:56 AM
The Alfresco JavaScript API can executed from various hook points. It can be used in Rules - so a script can be executed say when a document is uploaded or changed or when a new space is created or similar. It is also possible to execute a script directly via URL using the command servlet. Or you can configure a script to be executed when an action icon is clicked in the web-client UI.
http://wiki.alfresco.com/wiki/JavaScript_API
http://wiki.alfresco.com/wiki/URL_Addressability#Script_Command_Processor
http://wiki.alfresco.com/wiki/Externalised_Client_Actions#Action_Definition_Config_Elements
It cannot be used directly on a JSP page as it is executed withi the context of the server. However it can be used as part of the new Webscripts framework to build interactive pages with only some HTML/templating knowledge plus javascript:
http://wiki.alfresco.com/wiki/Web_Scripts
Hope this helps,
Kevin
http://wiki.alfresco.com/wiki/JavaScript_API
http://wiki.alfresco.com/wiki/URL_Addressability#Script_Command_Processor
http://wiki.alfresco.com/wiki/Externalised_Client_Actions#Action_Definition_Config_Elements
It cannot be used directly on a JSP page as it is executed withi the context of the server. However it can be used as part of the new Webscripts framework to build interactive pages with only some HTML/templating knowledge plus javascript:
http://wiki.alfresco.com/wiki/Web_Scripts
Hope this helps,
Kevin
