Create Programmatic Dynamic Forms
Graph Studio allows you to programmatically create dynamic forms using the Java (PGX) and Python (PGX) interpreters.
As a prerequisite step, you must first import the context that allows you to display the forms and define your own variable name and instantiate your context.
import oracle.datastudio.interpreter.common.context.JavaDataStudioContext
JavaDataStudioContext ds = interpreter.getJavaDataStudioContext()
from ds_interpreter_client.context.ds_context import PyDataStudioContext
ds = PyDataStudioContext()
ds
context allows you to display the forms and
define your own variable name.
The following steps describe the programmatic creation of the Textbox, Select, Select Multiple, Slider, Checkbox, Date Picker, Time Picker, and DateTime Picker forms.
- Create a Textbox dynamic form which allows you to input any string of
characters.
ds.textbox("<name>", "<default_value>")
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.default_value
(optional): The default value that is given to the dynamic form when it is first created.
For example:
Description of the illustration java_text_box.pngds.textbox(name="<name>", default_value="<default_value>")
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.default_value
(optional): The default value that is given to the dynamic form when it is first created.
For example:
Description of the illustration python_text_box.png - Create a Select dynamic form which allows you to select a value from a
drop-down menu.
import oracle.datastudio.common.forms.ParamOption List<ParamOption<String>> options = new ArrayList<>() options.add(new ParamOption<>("<option_value_a>", "<option_label_a>")) options.add(new ParamOption<>("<option_value_b>", "<option_label_b>")) ds.select("<name>", options, "<default_value>")
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.default_value
(optional): The default value that is given to the dynamic form when it is first created.
For example:
Description of the illustration java_select.pngoptions = [("<option_value_a>", "<option_label_a>"),("<option_value_b>", "<option_label_b>")] ds.select(name="<name>", options=options, default_value="<default_value>")
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.default_value
(optional): The default value that is given to the dynamic form when it is first created.
For example:
Description of the illustration python_select.png - Create a Select Mulitple dynamic form which allows you to select one or
more values from a drop-down list.
List<ParamOption<String>> options = new ArrayList<>(); options.add(new ParamOption<>("<option_value_a>", "<option_label_a>")); options.add(new ParamOption<>("<option_value_b>", "<option_label_b>")); List<String> defaultValues = new ArrayList<>(); defaultValues.add("<default_value>"); ds.selectMultiple("<name>", options, defaultValues, "<label>")
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.label
(optional): The label that is displayed on top of the dynamic form.default_value
(optional): The default value that is given to the dynamic form when it is first created. It must be one of the option values.- An option comprises
option_value
andoption_label
. Theoption_value
is used to reference whichdefault_value
should be selected, and the (optional)option_label
is displayed in the drop-down list. - An
option_value
can be either a string or a numeric value. - Options are separated with the
|
character in parsed forms.
- An option comprises
For example:
options = [('<option_value_a>', '<option_label_a>'),('<option_value_b>', '<option_label_b>')] ds.select_multiple(name='<name>', options=options, default_value=['<default_value>'], label='<label>')
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.label
(optional): The label that is displayed on top of the dynamic form.default_value
(optional): The default value that is given to the dynamic form when it is first created. It must be one of the option values.- An option comprises
option_value
andoption_label
. Theoption_value
is used to reference whichdefault_value
should be selected, and the (optional)option_label
is displayed in the drop-down list. - An
option_value
can be either a string or a numeric value. - Options are separated with the
|
character in parsed forms.
- An option comprises
For example:
- Create a Slider dynamic form which allows you to choose a number from a
given range.
ds.slider("<name>", <minimum>, <maximum>, <step_size>, <default_value>)
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.minimum
: The minimum value of the slider. Must be a number.maximum
: The maximum value of the slider. Must be a number.step_size
: The step size of the slider. Must be a number and divider of (maximum - minimum).default_value
(optional): The default value that is given to the dynamic form when it is first created (minimum <= default_value <= maximum
).
For example:
Description of the illustration java_slider.pngds.slider(name="<name>", min=<minimum>, max=<maximum>, step=<step_size>, default_value=<default_value>)
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.minimum
: The minimum value of the slider. Must be a number.maximum
: The maximum value of the slider. Must be a number.step_size
: The step size of the slider. Must be a number and divider of (maximum - minimum).default_value
(optional): The default value that is given to the dynamic form when it is first created (minimum <= default_value <= maximum
).
For example:
Description of the illustration python_slider.png - Create a Checkbox dynamic form which allows you to select one or
multiple values.
import oracle.datastudio.common.forms.ParamOption List<ParamOption<String>> options = new ArrayList<>() options.add(new ParamOption<>("<option_value_a>", "<option_label_a>")) options.add(new ParamOption<>("<option_value_b>", "<option_label_b>")) List<String> defaultValues = new ArrayList<>() defaultValues.add("<default_value>") ds.checkbox("<name>", options, defaultValues)
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.default_value
(optional): The default value that is given to the dynamic form when it is first created. It must be one of the option values:- An option comprises
option_value
andoption_label
. Theoption_value
is used to reference whichdefault_value
should be selected, and the (optional)option_label
is displayed in respective boxes created by a checkbox. - An
option_value
can be either a string or a numeric value. - Options are separated with the
|
character in parsed forms.
- An option comprises
For example:
Description of the illustration java_checkbox.bmpoptions = [("<option_value_a>", "<option_label_a>"),("<option_value_b>", "<option_label_b>")] ds.checkbox(name="<name>", options=options, default_value=["<default_value>"])
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.default_value
(optional): The default value that is given to the dynamic form when it is first created. It must be one of the option values:- An option comprises
option_value
andoption_label
. Theoption_value
is used to reference whichdefault_value
should be selected, and the (optional)option_label
is displayed in respective boxes created by a checkbox. - An
option_value
can be either a string or a numeric value. - Options are separated with the
|
character in parsed forms.
- An option comprises
For example:
Description of the illustration python_checkbox.png - Create a Date Picker dynamic form which allows you to select a
date.
ds.datePicker("<name>", "<date_format>", "<default_value>")
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.date_format
(optional, recommended): The date format that is used for displaying the selected date in the input field and for formatting the resulting date when the paragraph is run.default_value
(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thedate_format
or inyyyy-MM-dd
format if thedate_format
is not provided.
For example:
Description of the illustration java_date.pngds.date_picker(name="<name>", format="<date_format>", default_value="<default_value>")
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.date_format
(optional, recommended): The date format that is used for displaying the selected date in the input field and for formatting the resulting date when the paragraph is run.default_value
(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thedate_format
or inyyyy-MM-dd
format if thedate_format
is not provided.
For example:
Description of the illustration python_date_picker.png - Create a Time Picker dynamic form which allows you to select a
time.
ds.timePicker("<name>", "<time_format>", "<default_value>")
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.time_format
(optional, recommended): The time format that is used for displaying the selected time in the input field and for formatting the resulting time when the paragraph is run.default_value
(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thetime_format
or inHH:mm
format if thetime_format
is not provided.
For example:
Description of the illustration java_time.pngds.time_picker(name="<name>", format="<time_format>", default_value="<default_value>")
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.time_format
(optional, recommended): The time format that is used for displaying the selected time in the input field and for formatting the resulting time when the paragraph is run.default_value
(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thetime_format
or inHH:mm
format if notime_format
is provided.
For example:
Description of the illustration python_time_picker.png - Define a DateTime Picker dynamic form which allows you to select a date
and a time.
ds.dateTimePicker("<name>", "<dateTime_format>", "<default_value>")
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.dateTime_format
(optional, recommended): ThedateTime
format that is used for displaying the selected date and time in the input field and for formatting the resulting date and time when the paragraph is run.default_value
(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thedateTime_format
or inyyyy-MM-dd HH:mm
format if thedateTime_format
is not provided.
For example:
Description of the illustration java_date_time.pngds.date_time_picker("<name>", format="<dateTime_format>", default_value="<default_value>")
In the preceding code:
name
: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samename
to do so and it will only be displayed once.dateTime_format
(optional, recommended): ThedateTime
format that is used for displaying the selected date and time in the input field and for formatting the resulting date and time when the paragraph is run.default_value
(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thedateTime_format
or inyyyy-MM-dd HH:mm
format if thedateTime_format
is not provided.
For example:
Description of the illustration python_date_time_picker.png