Polish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
WalidatorWalidatory to komponenty użytkownika, umożliwiające sprawdzenie formularza podczas akceptacji zadania oraz zablokowanie akceptacji, gdy jakieś dane nie są prawidłowe. Przykładowe walidatory mogą np.
Stworzone walidatory dostępne są w edytorze procesów i mogą być łatwo wykorzystane w procesie biznesowym umożliwiając tym samym realizacje logiki biznesowej. Ich zachowanie może być dodatkowo konfigurowane za pomocą parametrów. Definiowanie walidatoraWalidatory tworzone są w oparciu o ich definicję stworzoną przez użytkownika. Definicja taka musi zawierać następujące elementy:
Walidator może również dostarczać skrypt, który buduje wygląd parametrów podczas jego definiowania w PWE. W tym celu należy dodać kolejną adnotację dla klasy
Przykładowa definicja przedstawiona jest poniżej:
Implementacja funkcji walidującejWalidator musi posiadać metodę walidującą o nazwie validate. Metoda może posiadać następujące typy parametrów:
W celu przerwania akceptacji zadania i wyświetlenia stosownego komunikatu należy dodać wiadomość do obiektu
Rejestracja walidatora we wtyczceJeżeli walidator jest definiowany 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:
Callback przy błędzie walidatoraMożliwe jest dodanie JavaScriptowej funkcji, która zostanie wywołana zamiast wyświetlenia okienka systemowego po zgłoszeniu błędu przez walidator. Jeżeli przycisk posiada wiele walidatorów, na pierwszym miejscu zostają wyświetlone błędy (okienka z błędami, podkreślanie zmiennych itp.) pochodzące ze zwykłych błędów walidatorów, a w tym czasie walidatory, który zgłosiły wywołanie callbacka zostaną zignorowane. Jeżeli użytkownik pozbył się wszystkich standardowych błędów, każda kolejna akceptacja zadania wywoła tylko i wyłącznie jeden pojedynczy callback. Aby dodać callback do komponentu, obok adnotacji
Aby zgłosić callback na formularzu, należy wywołać invokeCallback z
Jeżeli walidator jednocześnie doda błędy oraz zgłosi wywołanie callbacka, błędy zostaną zignorowane przez serwer (zostanie wywołany JavaScriptowy callback). Jeżeli walidator nie posiada adnotacji
Implementacja callbacka w JavaScripcie jest analogiczna do tworzenia skryptów Akcji.
Pierwszy argument funkcji create musi być taki sam, jak id walidatora. Drugim argumentem jest obiekt implementujący metodę callback, która jest wywoływana przy dodaniu błędu w walidatorze. Jeżeli chcemy zatwierdzić nasz walidator, żeby przepuścić akceptację dalej, musimy wywołać metodę walidatora this.confirm(). Jeżeli zostanie wywołane zatwierdzenie, to automatycznie zostanie wywołany callback kolejnego walidatoro (jeżeli taki będzie). W momencie, gdy wszystkie callbacki zostaną zatweirdzone, to nastąpi akceptacji z pominięciem tych walidatorów. Przekazanie argumentu do callbacka
Metoda invokeCallback pozwala przekazać dowolny obiekt, który następnie może być użyty przez skrypt po stronie przeglądarki. Obiekt ten zostanie skonwertowany do JSONa przez bibliotekę Jackson. Przykładowe użycie:
Po stronie JavaScriptu:
Komunikat błędu lub potwierdzenia walidacjiMożliwe jest określenie w PWE komunikatu błędu walidacji oraz komunikatu potwierdzenia akceptacji formularza pomimo błędu walidacji. Aby w PWE wyświetlone zostały te pola należy w builderze walidatora określić, jakie typy komunikatów mogą zostać skonfigurowane.
Enum
W metodzie execute walidatora możliwe jest pobranie dwóch nowych obiektów:
Obiekty te należy samemu dodać do błędów oraz potwierdzeń walidacji. Przykładowe użycie:
|
English | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ValidatorValidators are user components that allow you to check a form when accepting a task and block acceptance when some data is not correct. Examples of validators can, for example.
The created validators are available in the process editor and can be easily used in a business process, thus enabling the execution of business logic. Their behavior can be further configured using parameters. Defining a validatorValidators are created based on their definition created by the user. Such a definition must contain the following elements:
The validator can also provide a script that builds the appearance of parameters when it is defined in the PWE. To do this, add another annotation for the class
An example definition is shown below:
Validate function implementationThe validator must have a validating method named validate. The method can have the following parameter types:
In order to stop acceptance of the task and display the appropriate message, add a message to the object
Registration of the validator in the pluginIf the validator 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:
Callback on validator errorIt is possible to add a JavaScript function that will be called instead of displaying a system window when a validator reports an error. If the button has multiple validators, the errors (error boxes, variable underlining, etc.) from the usual validator errors are displayed first, and at that time the validators that reported the callback will be ignored. If the user has gotten rid of all the standard errors, each subsequent acceptance of the task will only call one single callback. To add a callback to a component, next to the annotation
To report a callback on the form, call invokeCallback with
If the validator simultaneously adds errors and reports a callback invocation, the errors will be ignored by the server (a JavaScript callback will be called). If the validator does not have annotation
an exception will be thrown when invokeCallback is called.
The implementation of callback in JavaScript is analogous to the creation of Actions scripts.
The first argument of the create function must be the same as the id of the validator. The second argument is the object that implements the callback method, which is called when an error is added to the validator. If you want to validate the validator to let the acceptance continue, you must call the validator method this.confirm(). If the validation is called, the callback of the next validator (if any) will automatically be called. Once all the callbacks have been validated, then the acceptance will happen, bypassing these validators. Forwarding an argument to a callback
The invokeCallback method allows you to forward any object, which can then be used by a browser-side script. This object will be converted to JSON by the Jackson library. Example usage:
JavaScript side:
Validation error or confirmation messageIt is possible to specify in the PWE a validation error message and a form acceptance confirmation message despite the validation error. In order to display these fields in the PWE, you need to specify in the validator builder which types of messages can be configured.
Enum
In the execute method of the validator, it is possible to retrieve two new objects:
These objects should be added to errors and validation confirmations. Example usage:
|