Przydatne linki


Zadanie zaplanowane

Zadanie zaplanowane to komponent użytkownika pozwalający na zdefiniowanie zadania wykonywanego okresowo.

Stworzenie zadania zaplanowanego możliwe jest w panelu administratora (Administracja -> Konfiguracja systemu -> Zadania zaplanowane)

Definiowanie zadania zaplanowanego

Zadanie zaplanowane tworzone jest w oparciu o definicję stworzoną przez użytkownika. Definicja taka musi zawierać następujące elementy:

  1. Adnotację @ScheduledTask (jeżeli zadanie zaplanowane nie jest definiowane we wtyczce, musi ono pochodzić z pakietu com.suncode)
  2. Publiczną metodę oznaczoną adnotacją @Define z jednym parametrem ScheduledTaskDefinitionBuilder
  3. Publiczną metodę o nazwie execute, która ma zostać wykonana okresowo. Metoda execute może zwracać dowolny typ włącznie z void. Zwrócona wartość będzie wyświetlona jako wynik przetwarzania zadania zaplanowanego. Ustawienie typu void jest jednoznaczne z brakiem rezultatu.

Definicja może zawierać również adnotację @ScheduledTaskScript. Adnotacja ta przekazuje ścieżkę do skryptu (z classpath) zawierającego definicję formularza dynamicznego.

Przykładowa definicja przedstawiona jest poniżej:

@ScheduledTask
@ScheduledTaskScript( "js/example-form.js" )
public class ExampleScheduledTask {
	@Define
	public void definition( ScheduledTaskDefinitionBuilder builder ) {
		builder
			.id( "example-scheduled-task" )
			.name( "example.scheduled.task.name" )
 			.description( "example.scheduled.task.desc" )
			.cancelable()
			.parameter()
				.id( "scheduled-task-param" )
				.name( "example.scheduled.task.param.name" )
				.description( "example.scheduled.task.param.desc" )
				.type( Types.STRING )
				.create();
	}
	
	public void execute( @Param( value = "scheduled-task-param" ) String param )
	{
		// Ciało zadania zaplanowanego
		...
	}
}

Od wersji 4.1.2 jest możliwość dodawania nowych parametry do istniejących zadań zaplanowanych pod warunkiem spełnienia minimum jednego z warunków:

  • parametr jest opcjonalny
  • (od wersji 4.1.5) parametr ma zdefiniowaną wartość domyślną

Przed tą wersją bezpośrednie rozszerzanie istniejących zadań zaplanowanych nie jest wspierane.

Implementacja metody execute

Zadanie zaplanowane musi posiadać metodę o nazwie execute. Metoda może posiadać następujące typy parametrów:

  • pojedynczy parametr zadania zaplanowanego - typ parametru musi być zgodny ze zdefiniowanym typem oraz musi być poprzedzony adnotacją @Param. Obsługiwane typy parametrów:
    • STRING
    • BOOLEAN
    • INTEGER
    • FLOAT
    • DATE - mapowane do org.joda.time.LocalDate (format yyyy-MM-dd)
    • DATETIME - mapowane do org.joda.time.LocalDateTime (format yyyy-MM-dd HH:mm:ss)
    • FILE - mapowanie do com.suncode.pwfl.customfile.ComponentFile
    • STRING_ARRAY
    • BOOLEAN_ARRAY
    • INTEGER_ARRAY
    • FLOAT_ARRAY
    • DATE_ARRAY
    • DATETIME_ARRAY
    • FILE_ARRAY
  •  - zawiera wszystkie zdefiniowane parametry zadania zaplanowanego wraz z ich wartościami, jest to alternatywa dla pobierania parametru za pomocą wyżej wspomnianej adnotacji @Param,
  •  - translator dla tego komponentu. Więcej informacji tutaj,
  •  - przechowuje informację o tym, czy użytkownik w GUI kliknął przycisk Anuluj wykonywanie. Sam mechanizm anulowania zadania musi zaimplementować twórca komponentu. Przycisk Anuluj wykonywanie pokaże się tylko, jeżeli w builderze została wywołana metoda cancelable,
  • Logger - logger do logowania własnych komunikatów w komponencie. Komunikaty są zapisywane do plików (skonfigurowanych w Log4j) oraz zostaną wyświetlone w historii wykonywania zadania.
  •  - obiekt, w którym ustawić można aktualny progress wykonywania zadania zaplanowanego (liczba między 0 a 1). Progress ten zostanie wyświetlony w GUI.
  •  - obiekt przechowujący informacje o danej instancji zadania zaplanowanego.

Rejestracja zadania zaplanowanego we wtyczce

Jeżeli zadanie zaplanowane jest definiowane we wtyczce to należy dodatkowo zaznaczyć, że wtyczka ta udostępnia komponenty. W tym celu należy w pliku suncode-plugin.xml dodać wpis:

<!-- Udostępnianie komponentów (m.in. zadań zaplanowanych) -->
<workflow-components key="components" />

 

Metoda jako zadanie zaplanowane we wtyczce

Zadanie zaplanowane we wtyczce nie musi być komponentem. Może zostać stworzone tak samo, jak zadania zaplanowane definiowane w projektach klienckich - zadanie zaplanowane jako wywołanie publicznej metody.

Np. po stworzeniu klasy we wtyczce:

package com.suncode.plugin;

public class SomePluginClass
{
    public void someMethod( String text, Integer number )
    {
        System.out.println( "Text: " + text + ", number: " + number );
    }
    public void someMethod2( String text, Double number )
    {
        System.out.println( "Text: " + text + ", number: " + number );
    }
}

Po wpisaniu com.suncode.plugin.SomePluginClass w pole Nazwa klasy w oknie dodawania nowego zadania zaplanowanego wyświetlone zostaną metody someMethod oraz someMethod2, które można wybrać i dodać jako zadanie zaplanowane.

Takie zadania mają jednak ograniczenia:

  • nie można użyć adnotacji  do nadania nazwy, opisu itd. dla zadania zaplanowanego
  • nie można przerwać takiego zadania
  • nie można ustawić progresu dla takiego zadania
  • nie można logować

Ze względu na powyższe ograniczenia funkcjonalność ta powinna służyć jedynie do testowania własnych klas we wtyczkach. Preferowane jest, aby docelowo zadania zaplanowane we wtyczkach były komponentami.

Jeśli zadanie zaplanowane jest napisane jako rozszerzenie klasy AbstractAdvancedTask i ma włączoną adnotację cancelable = true to by przerwać wykonywanie takiego zadania należy w kodzie metody dodać warunek:

if (Thread.currentThread().isInterrupted())
{
    taskLog.info( "Anulowano....");
    log.info( "Anulowano....");
    break;
}         

Dynamiczny formularz

Dynamiczny formularz umożliwia zdefiniowanie formularza parametrów zadania zaplanowanego.

Rejestracja dynamicznego formularza

Dynamiczny formularz rejestrowany jest poprzez przekazanie ścieżki do skryptu js (z classpath wtyczki) zawierającego definicję formularza dynamicznego w adnotacji @ScheduledTaskScript dodanej na poziomie klasy komponentu zadania zaplanowanego.

Przykładowa rejestracja skryptu na klasie po stronie Javy:

@ScheduledTask
@ScheduledTaskScript( "js/example-form.js" )
public class ExampleScheduledTask {
	@Define
	public void definition( ScheduledTaskDefinitionBuilder builder ) {
        builder
            .id( "example-scheduled-task" )  // identyfikator zadania zaplanowanego
            ...  // pozostałe parametry
    }
    
    ...
}

Przykładowa zawartość skryptu rejestrującego dynamiczny formularz po stronie Javascript:

// kluczem w metodzie register jest identyfikator zadania zaplanowanego
PW.ScheduledTasks.register('example-scheduled-task', {
    buildParams: function (form) {
        form.addCombobox({
            id: 'example-scheduled-task',
            values: [
                ['wartosc1', 'Wartosc 1'],
                ['wartosc2', 'Wartosc 2'],
                ['wartosc3', 'Wartosc 3']
            ]
        });
    }
}

 

Dostępne funkcje dynamicznego formularza

FunkcjaParametryOpis
addField(definition, [position])

definition - identyfikator dodawanego parametru

lub obiekt zawierający definicję pola

  • id - identyfikator dodawanego parametru

     

  • listeners - obiekt definiujacy funkcje zdarzeń na zmiennej

    • change - funkcja wywoływana, gdy zmieni się
      wartość pola.
      Funkcja może korzystać z następujących parametrów:
      • field- pole Combobox dla którego nastąpiła zmiana
      • newValue - nowa wartość pola

position - pozycja na której dodany mam zostać parametr.

Gdy position nie zostanie podany, parametr zostanie

dodany na końcu formularza.


Przykład dodania parametru:

...
form.addField('param-1');
...

Przykład dodania parametru z reagowaniem na zmianę wartości:

...
form.addField({
  id: "param-1",
  listeners: {
    change: function (field, newValue) {
      console.log(`Changed textfield to ${newValue}`);
    },
  },
});
...
 addTextArea(definition, [position])definition - identyfikator dodawanego parametru

lub obiekt zawierający definicję pola

position - pozycja na której dodany mam zostać parametr.

Gdy position nie zostanie podany, parametr zostanie dodany na końcu formularza.

listeners - obiekt definiujacy funkcje zdarzeń na zmiennej

  • change - funkcja wywoływana, gdy zmieni się
    wartość pola.
    Funkcja może korzystać z następujących parametrów:
    • field- pole dla którego nastąpiła zmiana
    • newValue - nowa wartość pola

Dodanie parametru jako pole typu `TextArea`.

Parametr musi być typu .

 

Przykład:

...
form.addTextArea('param-1');
...

lub

...
form.addTextArea({
	id: 'param-1',
	...
});
...
addCombobox(definition, [position])definition - obiekt zawierający definicję pola

Definicja powinna zawierać nastepujące pola:

  • id - identyfikator parametru (opcjonalne)
  • valueField - nazwa pola, ustawiającego
    wartość pola
  • displayField - nazwa pola, którego wartość
    zostanie wyświetlona w polu
  • minChars - minimalna liczba wpisanych znaków,
    po której Combobox rozpoczyna filtrowanie.
    Domyślnie: 0.
  • values - ((info) dla typu lokalnego) tablica rekordów wartości wyświetlanych pola; rekordem może być:
    • obiekt z polami valueField i displayField zdefiniowanymi w konfiguracji
    • tablica 2-elementowa z wartością oraz tekstem wyświetlanym
  • remote - ((info) dla typu zdalnego) obiekt zawierający
    definicję zdalnego pobierania danych. Obiekt zawiera
    następujące pola:
    • url - adres URL
    • params - obiekt zawierający pola z dokładanymi parametrami do żądań http

      • nazwa pola jest nazwą parametru żądania http
      • wartość pola jest wartością parametru żądania http
    • remoteSort - określa czy dane powinny
      być sortowane po stronie serwera (wartość true)
      czy po stronie przeglądarki (wartość false).
      Domyslnie false.
    • pageSize - liczba wyświetlanych wyników na stronie.
      Domyslnie 25.
  • sort - obiekt definiujących sposób sortowania.
    Zawiera następujące pola:
    • field - pole po jakim chcemy sortować
    • direction - kierunek po jakim chcemy sortować.
      ASC dla kierunku rosnącego,
      DESC dla kierunku malejącego.
  • listeners - obiekt definiujacy funkcje zdarzeń na zmiennej
    • change - funkcja wywoływana, gdy zmieni się
      wartość pola.
      Funkcja może korzystać z następujących parametrów:
      • field- pole dla którego nastąpiła zmiana
      • newValue - nowa wartość pola

position - pozycja na której dodany mam zostać parametr.

Gdy position nie zostanie podany, parametr zostanie dodany na końcu formularza

 

Endpoint zdalnego comboboxa ma następującą strukturę:

Parametry wysyłane:

  • query  - tekst wpisany w combobox (wymagany)
  • start - pozycja od której należy dokonywać szukania strony (wymagany)
  • limit - wielkość strony (wymagany)
  • sort - nazwa pola, po którym następuje sortowanie (gdy remoteSort jest włączone)
  • dir - kierunek sortowania po polu (gdy remoteSort jest włączone)

Dane zwracane:

  • data - tablica obiektów, któe mają strukturę zdefiniowaną parametrami valueField i displayField
  • total - liczba wszystkich dostępnych elementów
Dodanie parametru jako pole typu `Combobox`.

Przykład dodania pola typu 'Combobox' lokalnego (local):

...
form.addCombobox({
	id: 'param-1',
	values : [
        ['activity', 'Zadanie'],
		['stage', 'Etap'],
	    ['process', 'Proces']
    ],
	sort: {
		field: 'display',
		direction: 'DESC'
	},
	listeners: {
        change: function (field, newValue){
		    ...
	    }
    }
});
...

Przykład dodania pola typu 'Combobox' zdalnego (remote):

...
form.addCombobox({
	id: 'param-1',
	valueField: 'id',
	displayField: 'display',
	remote: {
		url: Suncode.getAbsolutePath('plugin/com.suncode.example-plugin/example-combo/get'),
        params: {
            userId: 'jankowalski'
        },
		remoteSort: false,
		pageSize: 20
	},
	sort: {
		field: 'display',
		direction: 'DESC'
	},
	listeners: {
        change: function (field, newValue){
		    ...
	    }
    }
});
...
setComboboxRemoteUrl(elementId, url)

elementId - identyfikator elementu

url - ades URL

Docelowy element musi być combobox'em typu zdalnego.

Przykład:

...
form.setComboboxRemoteUrl('param-1', Suncode.getAbsolutePath('plugin/com.suncode.example-plugin/example-combo/get'));
...
setComboboxRemoteParams(elementId, params)

elementId - identyfikator elementu

params - obiekt zawierający pola z dokładanymi parametrami do żądań http

  • nazwa pola jest nazwą parametru żądania http
  • wartość pola jest wartością parametru żądania http

Docelowy element musi być combobox'em typu zdalnego.

Przykład:

...
form.setComboboxRemoteParams('param-1', {
    userId: 'jankowalski'
});
...
addCheckbox(definition, [position])definition - identyfikator dodawanego parametru

lub obiekt zawierający definicję pola

position - pozycja na której dodany mam zostać parametr.

Gdy position nie zostanie podany, parametr zostanie dodany na końcu formularza.

listeners - obiekt definiujacy funkcje zdarzeń na zmiennej

  • change - funkcja wywoływana, gdy zmieni się
    wartość pola.
    Funkcja może korzystać z następujących parametrów:
    • field- pole dla którego nastąpiła zmiana
    • newValue - nowa wartość pola

Przykład:

...
form.addCheckbox('param-1');
...

Jeżeli podpinamy to pod parametr komponentu, to typ tego parametru musi być boolean.

addRow( [definition] )

definition - definicja wiersza.

Zawiera następujące pola:

  • id - identyfikator wiersza (opcjonalny)
  • fieldsSpace - odstęp w pikselach pomiędzy elementami wiersza. Domyślnie 5,
  • fieldLabel - nazwa (label) wiersza. Domyślnie nazwa wiersza tworzona jest na podstawie nazw elementów zawartych w wierszu.

Dodaje i zwraca "pusty" wiersz. Zwrócony wiersz umożliwia dodanie do niego pól. Pola będą dodawane obok siebie.

Przykład:

var row = form.addRow();
row.addField('param-1');
row.addField('param-2');
row.addCombobox(...);
addTable( [definition] )

definition - definicja tabeli.

Zawiera następujące pola:

  • id - identyfikator tabeli (opcjonalny)
  • fieldLabel - nazwa (label) tabeli (opcjonalny) - domyślnie brak

Dodaje i zwraca "pustą" tabele. Zwrócona tabela umożliwia dodanie do niej parametrów tablicowych jako kolumn tabeli. Pola tablicowe będą wyświetlane obok siebie i razem pogrupowane.

Inne elementy niż parametry tablicowe nie są wspierane.

Przykład:

var table = form.addTable({
    fieldLabel: "Przykładowa tabela"
});
table.addField('param-1');
table.addField('param-2');
table.addCombobox(...);
addButton(definition, [position] )

definition - definicja przycisku.
Zawiera następujące pola:

  • id - identyfikator przycisku
  • text - wyświetlany tekst przycisku
  • handler - funkcja wywołująca się po kliknieciu przycisku

position - pozycja na której dodany mam zostać parametr.

Gdy position nie zostanie podany, parametr zostanie dodany na końcu formularza

Dodanie przycisku na formularzu.

Przykład:

form.addButton({
	id: 'btn-1',
	text: 'Przycisk',
	handler: function(){
	...
	}
})
addPassword(definition, [position])definition - identyfikator dodawanego parametru lub obiekt zawierający definicję pola

position - pozycja na której dodany mam zostać parametr.

Gdy position nie zostanie podany, parametr zostanie dodany na końcu formularza.

listeners - obiekt definiujacy funkcje zdarzeń na zmiennej

  • change - funkcja wywoływana, gdy zmieni się
    wartość pola.
    Funkcja może korzystać z następujących parametrów:
    • field- pole dla którego nastąpiła zmiana
    • newValue - nowa wartość pola

Dodanie parametru jako pole typu 'Password'.

Parametr musi być typu .

Przykład:

...
form.addPassword('param-1');
...

lub

...
form.addPassword({
	id: 'param-1',
	...
});
...
hide(elementId)elementId - identyfikator elementu

Ukrywa pole o podanym id.

Przykład

...
form.hide('param-1');
...
show(elementId)elementId - identyfikator elementu

Pokazuje pole o podanym id.

Przykład:

...
form.show('param-1');
...
disable(elementId)elementId - identyfikator elementu

Wyłącza możliwość edycji pola o podanym id.

Przykład:

...
form.disable('param-1');
...
enable(elementId)elementId - identyfikator elementu

Włącza możliwość edycji pola o podanym id.

Przykład:

...
form.enable('param-1');
...
getValue(elementId)elementId - identyfikator elementu

Pobiera wartość parametru o podanym id.

Przykład:

...
form.getValue('param-1');
...
setValue(elementId, value)

elementId - identyfikator elementu

value - wartość do ustawienia

Ustawia przekazaną wartość do parametru o podanym id.

Dla typów tablicowych wartością jest tablica wartości.

Przykład:

...
form.setValue('param-1', 'value');
...

setRequired(elementId, value)

Dostępne od wersji 4.1.3

elementId - identyfikator elementu

value - wymagalność parametru

Dostępne od wersji 4.1.3.

Ustawia wymagalność parametru o podanym id.

Tylko parametry zadeklarowane wstępnie jako opcjonalne mogą mieć zmienioną wymagalność na formularzu.

Przykład:

...
form.setRequired('param-1', true);
...
mask(onlyForm)

onlyForm - prawda by nałożyć maskę tylko na formularz parametrów, fałsz by nałożyć maskę na zawartość całego okna.

Nakłada maskę na formularz parametrów lub zawartość okna.

Przykład:

...
form.mask(false);
...
unmask(onlyForm)

onlyForm - prawda by usunąć maskę tylko z formularza parametrów, fałsz by usunąć maskę z zawartości całego okna

Usuwa maskę z formularza parametrów lub zawartości okna.

Przykład:

...
form.unmask(false);
...



Helpful links


Scheduled task

Scheduled task is a user component that allows you to define a task that is performed periodically.

Creating a scheduled task is possible in the admin panel (Administration -> System configuration -> Scheduled tasks).


Defining a scheduled task

A scheduled task is created based on a definition created by the user. Such a definition must contain the following elements:

  1. Annotation @ScheduledTask (if the scheduled task is not defined in the plugin, it must come from the com.suncode package)
  2. A public method marked with the annotation @Define witch a single parameter ScheduledTaskDefinitionBuilder
  3. A public method named execute to be executed periodically. The execute method can return any type including void. The returned value will be displayed as the result of scheduled task processing. Setting the type void is equivalent to no result.

The definition may also contain the @ScheduledTaskScript annotation. This annotation transfers the path to the script (from classpath) containing the definition of the dynamic form.

An example definition is shown below:

@ScheduledTask
@ScheduledTaskScript( "js/example-form.js" )
public class ExampleScheduledTask {
	@Define
	public void definition( ScheduledTaskDefinitionBuilder builder ) {
		builder
			.id( "example-scheduled-task" )
			.name( "example.scheduled.task.name" )
 			.description( "example.scheduled.task.desc" )
			.cancelable()
			.parameter()
				.id( "scheduled-task-param" )
				.name( "example.scheduled.task.param.name" )
				.description( "example.scheduled.task.param.desc" )
				.type( Types.STRING )
				.create();
	}
	
	public void execute( @Param( value = "scheduled-task-param" ) String param )
	{
		// Body of scheduled task
		...
	}
}

Implementation of the execute method

A scheduled task must have a method named execute. The method can have the following parameter types:

  • a single scheduled task parameter - the parameter type must conform to the defined type and must be preceded by the @Param annotation. Supported parameter types:
    • STRING
    • BOOLEAN
    • INTEGER
    • FLOAT
    • DATE - mapping to org.joda.time.LocalDate (yyyy-MM-dd format)
    • DATETIME - mapping to org.joda.time.LocalDateTime (yyyy-MM-dd HH:mm:ss format)
    • FILE - mapping to com.suncode.pwfl.customfile.ComponentFile
    • STRING_ARRAY
    • BOOLEAN_ARRAY
    • INTEGER_ARRAY
    • FLOAT_ARRAY
    • DATE_ARRAY
    • DATETIME_ARRAY
    • FILE_ARRAY
  •  - contains all the defined parameters of a scheduled task along with their values, this is an alternative to retrieving a parameter using the mentioned @Param annotation
  •  - translator for this component. More information here,
  •  - stores information about whether the user in the GUI clicked the Cancel execution button. The task cancellation mechanism itself must be implemented by the component developer. The Cancel Execution button will only show up if the cancelable method has been called in the builder,
  • Logger - a logger for logging custom messages in the component. Messages are saved to files (configured in Log4j) and will be displayed in the task execution history.
  •  - object, in which you can set the current progress of the scheduled task execution (a number between 0 and 1). This progress will be displayed in the GUI
  •  - an object that stores information about a given instance of a scheduled task

Registration of a scheduled task in the plugin

If the scheduled task is defined in the plugin then you need to additionally indicate that the plugin provides components. To do this, add an entry in the suncode-plugin.xml file:

<!-- Sharing components (among other scheduled tasks) -->
<workflow-components key="components" />

 

Method as a task scheduled in a plugin

A scheduled task in a plugin does not have to be a component. It can be created in the same way as scheduled tasks defined in client projects - a scheduled task as a public method call.

For example, after creating a class in a plug-in

package com.suncode.plugin;

public class SomePluginClass
{
    public void someMethod( String text, Integer number )
    {
        System.out.println( "Text: " + text + ", number: " + number );
    }
    public void someMethod2( String text, Double number )
    {
        System.out.println( "Text: " + text + ", number: " + number );
    }
}

After typing com.suncode.plugin.SomePluginClass in the Class Name field, the window for adding a new scheduled task will display someMethod1 and someMethod2 methods, which can be selected and added as a scheduled task.

However, such tasks have limitations:


  • annotation  cannot be used to give a name, description, etc. for a scheduled task
  • you cannot abort that kind of task
  • you cannot set progression for this kind of task
  • you cannot log

Due to the above limitations, this functionality should only be used for testing custom classes in plugins. It is preferred that ultimately the tasks scheduled in plugins are components.

If a scheduled task is written as an extension of the AbstractAdvancedTask class and has the cancelable = true annotation enabled, then to stop the execution of such a task you need to add a condition in the method code:

if (Thread.currentThread().isInterrupted())
{
    taskLog.info( "Anulowano....");
    log.info( "Anulowano....");
    break;
}         

Dynamic form

The dynamic form allows you to define a scheduled task parameter form.

Dynamic form registration

PW.ScheduledTasks.register('example-scheduled-task', {
    buildParams: function (form) {
        form.addCombobox({
            id: 'example-scheduled-task',
            values: [
                ['wartosc1', 'Wartosc 1'],
                ['wartosc2', 'Wartosc 2'],
                ['wartosc3', 'Wartosc 3']
            ]
        });
    }
}

If, when adding an element to the form, you define the id of the element and this value refers to the id of the parameter defined in the component, then all properties for the field will be read from the parameter definition (name, description, requirement, type).

If, on the other hand, you want to add a field that is not related to any parameter, then you should define the name, description, type and requirement.

Available functions of the dynamic form

FunctionParametersDescription
addField(definition, [position])

definition - identifier of the added parameter

or object containing the definition of the field

position - the position at which the parameter is to be added.

When position is not specified, the paramter will be added at the end of the form.

listeners - an object that defines the function of events on the variable

  • change - a function called when the value of a field changes.

    The function can use the following parameters:
    • field- the Combobox field for which the change occurred
    • newValue - the new value of the field


Adding parameter.

Example:

...
form.addField('param-1');
...

If we add a field unrelated to the component parameter, we can specify what type the field should be.

The following types are available: string, integer, float, date, datetime, boolean, string[], integer[], float[], date[], datetime[], boolean[].

...
form.addField({
	id: 'custom',
	fieldType: 'date',
	...
});
...
 addTextArea(definition, [position])definition - identifier of the added parameter

or object containing the definition of the field

position - the position at which the parameter is to be added.

When position is not specified, the paramter will be added at the end of the form.

listeners - an object that defines the function of events on the variable

  • change - a function called when the value of a field changes.

    The function can use the following parameters:
    • field - the field for which the change occurred
    • newValue - the new value of the field

Adding a parameter as a field of type `TextArea`.

Parameter must be of type .

 

Example

...
form.addTextArea('param-1');
...

or

...
form.addTextArea({
	id: 'param-1',
	...
});
...
addCombobox(definition, [position])definitionobject containing the definition of a field

The definition should contain the following fields:

  • id - identifier of the parameter (optional)
  • valueField -  name of the field, setting the the value of the field
  • displayField - the name of the field whose value will be displayed in the field
  • minChars - the minimum number of entered characters, after which Combobox starts filtering.
    Default: 0.
  • values - ((info) for local type) an array of records of field display values; a record can be:
    • an object with valueField and displayField fields defined in the configuration
    • a 2-element array with value and display text
  • remote - ((info) for remote type) object containing the definition of remote data retrieval. The object contains the following fields:
    • url - URL address
    • remoteSort - determines whether the data should be sorted on the server side (value true) or on the browser side (value false).
      The default is false.
    • pageSize - amount of displayed results per page.
      Default is 25.
  • sort - object defining the method of sorting.
    It contains the following fields:
    • field - the field by which we want to sort
    • direction - the direction by which we want to sort.
      ASC for ascending direction,
      DESC for descending direction.
  • listeners - an object that defines the function of events on the variable
    • change - a function called when the value of a field changes.
      The function can use the following parameters:
      • field - the field for which the change occurred
      • newValue - the new value of the field

position - The position on which the parameter is to be added.

When position is not specified, the parameter will be added to the end of the form

 

Adding a parameter as a field of type `Combobox`.

Example of adding a field of type `Combobox` local (local):

...
form.addCombobox({
	id: 'param-1',
	values : [
        ['activity', 'Zadanie'],
		['stage', 'Etap'],
	    ['process', 'Proces']
    ],
	sort: {
		field: 'display',
		direction: 'DESC'
	},
	listeners: {
        change: function (field, newValue){
		    ...
	    }
    }
});
...

Example of adding a field of type 'Combobox' remote (remote):

...
form.addCombobox({
	id: 'param-1',
	valueField: 'id',
	displayField: 'display',
	remote: {
		url: Suncode.getAbsolutePath('plugin/com.suncode.example-plugin/example-combo/get'),
		remoteSort: false,
		pageSize: 20
	},
	sort: {
		field: 'display',
		direction: 'DESC'
	},
	listeners: {
        change: function (field, newValue){
		    ...
	    }
    }
});
...
addCheckbox(definition, [position])definition - identifier of the added parameter

or object containing the definition of the field

position - the position at which the parameter is to be added.

When position is not specified, the paramter will be added at the end of the form.

listeners - an object that defines the function of events on the variable

change - a function called when the value of a field changes.

The function can use the following parameters:
  • field - the field for which the change occurred
  • newValue - the new value of the field

Example:

...
form.addCheckbox('param-1');
...

If we pin this to a component parameter, the type of this parameter must be boolean.

addRow( [definition] )

definition - definition of a row.

It contains the following fields:

  • id - row identifier (optional).
  • fieldsSpace -space in pixels between elements of the row. The default is 5
  • fieldLabel - the name (label) of the row. By default, the row name is created based on the names of the elements contained in the row.

Adds and returns an "empty" row. The returned row allows you to add fields to it. The fields will be added side by side.

Example:

var row = form.addRow();
row.addField('param-1');
row.addField('param-2');
row.addCombobox(...);
addButton(definition, [position] )

definition - button definition.
It contains the following fields:

  • id - button identifier
  • text - the displayed text of the button
  • handler - function that is called when the button is clicked

position - the position at which the parameter is to be added.

When position is not specified, the paramter will be added at the end of the form.

Adding a button on the form.

Example:

form.addButton({
	id: 'btn-1',
	text: 'Przycisk',
	handler: function(){
	...
	}
})
addPassword(definition, [position])definition - the identifier of the added parameter or the object containing the field definition

position - the position at which the parameter is to be added

If position is not specified, the parameter will be added at the end of the form.

listeners - an object that defines event functions on the variable

  • change - a function called when the value of the value of the field.

    Funkcja może korzystać z następujących parametrów:
    • The function can use the following parameters:
      • field - the field for which the change occurred
      • newValue - the new value of the field

Adding a parameter as a field of type 'Password'.

Parameter must be of type.

Example

...
form.addPassword('param-1');
...

or

...
form.addPassword({
	id: 'param-1',
	...
});
...
hide(elementId)elementId - element identifier

Hides the field with the specified id.

Example

...
form.hide('param-1');
...
show(elementId)elementId - element identifier

Hides the field with the specified id.

Example

...
form.show('param-1');
...
disable(elementId)elementId - element identifier

Hides the field with the specified id.

Example

...
form.disable('param-1');
...
enable(elementId)elementId - element identifier

Hides the field with the specified id.

Example

...
form.enable('param-1');
...
getValue(elementId)elementId - element identifier

Hides the field with the specified id.

Example

...
form.getValue('param-1');
...
setValue(elementId, value)

elementId - element identifier

value - value to be set

Sets the forwarded value to the parameter with the specified id.

For array types, the value is an array of values.

Example

...
form.setValue('param-1', 'value');
...
mask(onlyForm)

onlyForm - true - to apply the mask only to the parameter form, false - to apply the mask to the contents of the entire window.

Applies a mask to a parameter form or window content.

Example

...
form.mask(false);
...
unmask(onlyForm)

onlyForm - true - to apply the mask only to the parameter form, false - to apply the mask to the contents of the entire window.

Applies a mask to a parameter form or window content.

Example

...
form.unmask(false);
...