Alfresco has the ability to process server-side javascript via an external command processor (Alfresco Wiki). Any output of the script is then returned to the browser as HTML, meaning quite complex interfaces can be built without any Java code.
The following is a simple request processor that uses the idea of MVC (loosely…) with Action Controllers to process different actions and views depending on what method the user triggers. There’s some limitations as to what you can push through to the Freemarker templates, so some of the logic is needed in there, however overal it’s possible to do some quite sophisticated things.
Main entry point is JSRequest.prototype.doRequest
- figures out what request action to execute based on an “action” parameter in the request (ie you need to specify one as a hidden field on your forms)
- executes that action, getting a string back as the output of that action
- wraps a global template (if it exists) around the whole lot for theming purposes.
The example includes just a simple search demonstration. The javascript is actually inside the .html files; you may need to change some of the config settings at the top of the files to make sure of the context path etc.
(Edited to add: you access it via a url like http://localhost:8080/alfresco/command/script/execute?scriptPath=/Company%20Home/web-scripts/index.html)
Javascript request processing example