Using the Script Component

1,614 views Published on Nov 29, 2013
Applies to: All versions

WebRatio gives at your disposal a predefined set of view components and operations that let you model most of the features of your Web application. Sometimes it happens that WebRatio does not include a specific business logic that you need. In this case you can address the problem creating custom components or adding a Script Component to the Web Project. The Script Component is a component that let you write your own custom algorithm in a dedicated file and then reference this file in a specific point of the Web Project. Starting from that file, the Script prepares its input and output so that it’s possible to make parameter bindings. A Components Project is a project in which you can create your own custom components and then use them inside the Web Project as the standard ones. These components may also be reused in different Web Projects, depending on your needs. How to choose between a Script Component and a custom component implementing the desired business logic? Well, the answer depends on the kind of usage you want to make of the custom business logic you need. If the business logic is a general needs (e.g. reading or writing an excel file), then the suggestion is to create a custom component that implement that business logic because you will reuse it sooner or later. If the business logic is strictly related to some pages or action definitions of the Web project you are working on, then you should use a Script Component because you are not going to reuse the same logic in other projects. Anyhow when the business logic become so complex that you are going to write many line of script codes it’s better to use a custom component where you can easily debug the code if you face an error. This document guides you in the Script Components usage, giving you the basic knowledge in order to be able to write your own algorithms and the best practices for the project organization. Moreover, this document presents some common uses cases with the related code.