Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Alfresco Web Scripts

You're reading from   Learning Alfresco Web Scripts Learn a powerful way to successfully implement unique integration solutions with Alfresco

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher
ISBN-13 9781784390600
Length 182 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Ramesh Chauhan Ramesh Chauhan
Author Profile Icon Ramesh Chauhan
Ramesh Chauhan
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Getting Familiar with Web Scripts 2. It's Time for the First Web Script FREE CHAPTER 3. Understanding the Web Script Framework 4. Building Blocks of Web Scripts 5. Invoking Web Scripts 6. Creating Java-backed Web Scripts 7. Understanding JavaScript-based Web Scripts in Detail 8. Deployment, Debugging, and Troubleshooting Web Scripts 9. Mavenizing Web Scripts 10. Extending the Web Script Framework Index

Understanding how web scripts work

Web scripts in Alfresco mostly use the model-view-controller pattern. However, it isn't mandatory to follow this pattern all the time. The way MVC pattern works in web scripts is as follows:

  • The controller is responsible for performing the required business logic as per the business requirement. After processing the business logic, controller populates the model object with the required data. Once this is done, controller will then forward the request to the view.

MVC in web scripts

The model-view-controller pattern in web scripts is explained as follows:

  • The controller is a server-side JavaScript or Java class or it could be both as well
  • The model is a data structure object passed between the controller and view
  • The view is a FreeMarker template that is responsible for generating the response in the required format

The mapping of the web script URI to the controller is done through a descriptor file. It is mainly an XML file that will have the required details for a web script such as URL, description, arguments, transaction, authentication, and response formats.

Response formats are mapped to FreeMarker templates through naming conventions. For example, a FreeMarker template that returns an HTML response will have the extension html.ftl.

Web scripts are registered and executed by the web script engine in Alfresco.

Note

A descriptor, optional controller, and one or more FreeMarker response templates collectively make a web script in general scenarios.

All these components are tied together through a specific document naming convention.

Making web scripts work

To make web scripts work, it is important to deploy the web script files at an appropriate location.

The descriptor file and the FreeMarker template as per the response format for a web script can be either placed on a filesystem or put into the Alfresco repository.

If a JavaScript-based controller is used for a web script, then it could be placed along with the descriptor and FreeMarker template on a filesystem or in the Alfresco repository.

If a Java-based controller is used for a web script, then the class file for the controller must be available on the class path.

Note

There are two types of controllers available for web scripts: JavaScript-based controllers and Java-based controllers. It is possible to have none of them, either of them, or even both of them for a web script.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime