Widget and validation gallery

This gallery shows how widgets and validations are rendered in both Studio and web environments, along with sample implementation code.

Widgets

Widgets allow to easily implement different types of input fields to your components.

Input/Text

@Option
String config;

Password

@Option
@Credential
String config;

Textarea

@Option
@Textarea
String config;

Integer

@Option
@Documentation("This is a number")
public Integer number;

Checkbox

@Option
Boolean config;

List

@Option
@Proposable("valuesProvider")
String config;
/** service class */
@DynamicValues("valuesProvider")
public Values actions(){
  return new Values(asList(new Values.Item("1", "Delete"),
                    new Values.Item("2", "Insert"),
                    new Values.Item("3", "Update")));
}

or

@Option
ActionEnum config;

/** Define enum */
enum ActionEnum {
    Delete,
    Insert,
    Update
}

Suggestions

@Option
@Suggestable(value = "loadModules", parameters = { "myconfig" })
@Documentation("module names are loaded using service")
public String moduleName;


// In Service class
@Suggestions("loadModules")
public SuggestionValues loadModules(@Option final MyConfig myconfig) { }

Table

@Option
List<MyObject> config;

Code

@Code("java")
@Option
String config;

Schema

@Option
@Structure
List<String> config;

Validations

Validations help restricting what can be entered or selected in an input field, to make sure that the value complies with the expected type of information.

Property validation

/** configuration class */
@Option
@Validable("url")
String config;

/** service class */
@AsyncValidation("url")
ValidationResult doValidate(String url) {
//validate the property
}

Property validation with Pattern

/** configuration class */
@Option
@Pattern("/^[a-zA-Z\\-]+$/")
String username;

Data store validation

@Datastore
@Checkable
public class config {
/** config ...*/
}

/** service class */
@HealthCheck
public HealthCheckStatus testConnection(){

//validate the connection
}

You can also use other types of validation that are similar to @Pattern:

  • @Min, @Max for numbers.

  • @Unique for collection values.

  • @Required for a required configuration.

Scroll to top