Uno de los temas a los cuales me costó más entrarle en el mundo de los formularios Adobe de SAP (SAP Interactive forms by Adobe - IFbA) es el de scripting y en particular los diálogos o popups. Me fue bastante difícil conseguir documentación y ejemplos de estos temas. Quizás la principal documentación con la que pude contar fue la guía de referencia de javascript y la ayuda online de Adobe, pero definitivamente no encontré documentación en castellano. Esta serie de posts irá dedicada a mostrar en forma sencilla cómo programar diálogos con javascript para principiantes y será seguida de otra serie de posts para desarrolladores experientes.
¿Qué comentar de los diálogos de Adobe? A primera vista parecen bastante limitados en sus funcionalidades, pero con un poco de imaginación podremos sacarle el jugo necesario para resolver las situaciones más comunes y algunas más complejas.
Las básicas
Para crear diálogos vamos a utilizar el método execDialog del objeto app. Este método recibe como parámetro un objeto monitor el cual consta de los manejadores de eventos y una propiedad description que representa el contenido del diálogo. Retorna un string con el ItemId del elemento que hizo que el diálogo se cerrara. e.g. si el elemento es un botón ok_cancel, retorna "ok" o "cancel".
Manejadores
El objeto Dialog tiene 5 manejadores (funciones):
initialize - se ejecuta cuando la ventana de diálogo se crea
validate - se ejecuta al validar los valores de los campos
commit - se ejecuta al presionar el botón OK
destroy - se ejecuta cuando se destruye la ventana de diálogo
itemID - se ejecuta cuando se modifica la propiedad itemID de un objeto
Todos los métodos manejadores reciben como parámetro un objeto Dialog que es la instancia del diálogo creado.
Propiedades del diálogo
Como decíamos, la propiedad description contiene una serie de propiedades del diálogo como name (nombre), width (ancho), height (alto). Su propiedad más importante es elements, la cual contiene un vector de objetos que representan los distintos objetos de la ventana.
Ejemplos de estos objetos son un cuadro de texto, una etiqueta, un botón o un contenedor.
Métodos
El objeto Diálogo (el cual es pasado a los manejadores) tiene una serie de métodos de los cuales los más importantes son load y store.
El método load se utiliza para cargar valores a los objetos del diálogo y el método store para obtener los valores de los objetos del diálogo.
En el siguiente post
En el siguiente post realizaremos un ejemplo sencillo de un diálogo utilizando tanto notación convencional de java como notación literal.
English version
One of the most difficult topics I found when starting in the SAP Interactive Forms by Adobe (IFbA) world was scripting and particularly dialogs. In my experience it is very difficult to find documentation and examples of this topic, specially in Spanish. Perhaps the main documentation that I could find was the javascript for Interactive Forms reference and the Adobe online Help, but definitely I couldn’t find anything in Spanish. This post series will be dedicated to demonstrate an easy way of programming dialogs with javascript for beginners. It will be followed by another series for experienced developers.
What do I have to say about Adobe dialogs? At first sight they seem raher limited in their functionality, but with some imagination we can squeeze the technology to solve the most common situations and some complex ones too.
The basics
We'll use the execDialog method in the app object for creating dialogs. This method receives a monitor object as a parameter which is compound by event handlers and a description property which represents the dialog contents. It returns an string with te ItemId property of the element that made the dialog close. e.g. if the element is the ok_cancel button it will return "ok" or "cancel".
Handlers
The dialog has 5 handlers:
initialize - triggered at dialog creation
validate - triggered when validating field values
commit - triggered when OK button is pressed
destroy - triggered when a dialog window is destroyed
itemID - triggered when the itemID property of an object is modified
All these handlers receive a Dialog object as a parameter, which is the instance of the created dialog.
Dialog properties
As we mentioned above, the description property contains a series of dialog properties such as name, width and height. It's most important property is elements which contains an array of objects that represent the different objects of the window.
Examples of these objects are textbox, caption, button or a container.
Methods
The Dialog object (the instance passed to the handlers) has a series of methods out of which the most important are load and store.
The load method is used to load the values to the dialog objects and the store methods to get these values from the dialog object.
Next
In the next post we'll program an easy dialog using both conventional java notation and literal notation.