The Form UDR
is used to create a form which that includes other components were a user where you can enter data to be sent to workflow.
...
The You can use the following APL code to produce the above example is thiscreate a form as shown above:
Code Block |
---|
//Create the Form UDR
Form searchform = udrCreate(Form);
searchform.method = searchform.METHOD_POST;
//Create the textfield to be included in the form.
TextField searchText = udrCreate(TextField);
searchText.id = "search";
//Must include name otherwise the data can not be sent to workflow
searchText.name = "search";
searchText.placeholder = "Filter Results";
//Create the send button
Button searchButton = udrCreate(Button);
searchButton.buttonType = searchButton.SUBMIT;
searchButton.text = "Search";
//Add the components to the form
searchform.components = listCreate(ComponentUDR, searchText, searchButton); |
A Another example of a form example that uses a grid to place the components.
...
The APL code to produce the above example is this:
Expand |
---|
|
Code Block |
---|
// Create text fields
TextField userTextField = udrCreate(TextField);
userTextField.name = "username";
userTextField.label = "Create a username";
TextField aliasTextField = udrCreate(TextField);
aliasTextField.name = "alias";
aliasTextField.label = "Create an alias";
// Create a radio button group
RadioButtonGroup radioButton = udrCreate(RadioButtonGroup);
radioButton.name = "radioButton";
radioButton.label = "Select a color";
// Create a ordered map to control the order of the radio button
radioButton.buttons = mapCreateOrdered(string, string);
mapSet(radioButton.buttons, "Red", "red");
mapSet(radioButton.buttons, "Blue", "blue");
mapSet(radioButton.buttons, "Green", "green");
// Create integer fields
IntegerField portIntegerField = udrCreate(IntegerField);
portIntegerField.label = "Port";
portIntegerField.name = "port";
IntegerField timeoutIntegerField = udrCreate(IntegerField);
timeoutIntegerField.label = "Timeout";
timeoutIntegerField.name = "timeout";
// Create a dropdown
DropDown dropdown = udrCreate(DropDown);
dropdown.name = "dropdown";
dropdown.label = "Dropdown";
dropdown.items = mapCreateOrdered(string, string);
mapSet(dropdown.items, "Select an item", "");
mapSet(dropdown.items, "First Value", "first");
mapSet(dropdown.items, "Second Value", "second");
// Create a button to be used as the submit button in the form
Button formSubmitButton = udrCreate(Button);
formSubmitButton.text = "Submit";
formSubmitButton.buttonType = formSubmitButton.SUBMIT;
// Create a grid to be used in the form
Grid formGrid = udrCreate(Grid);
formGrid.rows = listCreate(GridRow);
// Add the columns to a row, and then insert that row into the formGrid's rows.
// To simplify the creation of columns and rows, they have been moved to helper functions.
listAdd(formGrid.rows, getRow([getColumn(userTextField, 6), getColumn(aliasTextField, 6)]));
listAdd(formGrid.rows, getRow([getColumn(radioButton, 0)]));
listAdd(formGrid.rows, getRow([getColumn(portIntegerField, 6), getColumn(timeoutIntegerField, 6)]));
listAdd(formGrid.rows, getRow([getColumn(dropdown, 0)]));
listAdd(formGrid.rows, getRow([getColumn(formSubmitButton, 0)]));
// Create the form UDR
Form form = udrCreate(Form);
form.method = form.METHOD_POST;
// Add the grid, which was created for the form and holds the components, as a component of the form.
form.components = listCreate(ComponentUDR, formGrid); |
|
Code Block |
---|
// Helper functions for column and row
GridColumn getColumn(ComponentUDR comp, int width){
GridColumn col = udrCreate(GridColumn);
if(width > 0){
col.width = width;
}
col.components = listCreate(ComponentUDR, comp);
return col;
}
GridRow getRow(list<GridColumn> columns){
GridRow row = udrCreate(GridRow);
row.columns = listCreate(GridColumn);
for (GridColumn column: columns) {
listAdd(row.columns, column);
}
return row;
} |
...