APEX ITEM and Dynamic Tabular Forms
APEX ITEM and Dynamic Tabular Forms
APEX ITEM and Dynamic Tabular Forms
Agenda
Example Form
Built in Update
Built in Insert
Column Attributes
Column Attributes
Report Source
SQL
, apex_item.radiogroup(ROWNUM, radio_value,
selected_value, value_label) as radiobutton
FROM wherever
WHERE whatever
Column
Attributes
APEX_ITEM API
wwv_flow.accept
Page Process
Column Attributes
Missing Elements
Checkbox
Radiobutton
PopupKey
Post Processing
For the simplest tabular reports use the
APEX_ITEM.MULTI_ROW_UPDATE
procedure
Takes an MRU string in the format:
OWNER:TABLE:pk_col1,pk_idx:pk_col2,p_idx2|col,idx:col:idx..
APEX_ITEM.MULTI_ROW_UPDATE(
SCOTT:EMP:EMP_ID,1|EMP_FNAME,2:EMP_LNAME,3);
END;
Simple
All or nothing
1
2
3
g_f01
13432
14567
g_f02 g_f03
4
1
g_f50
g_fcs
..B2449..
..A3609..
..Z8134..
Tabular form elements are posted to server and then stored in the
apex_application arrays
The name attribute of the item corresponds with the array name
G_fcs is populated by md5_checksum function
Non selected checkboxes and radio buttons (and disabled elements) are not
posted
APEX_ITEM Package
Functions that
return HTML input
items
Procedure for
updating multiple
records
Checkbox
Checksum
Date Popup
Display only
Hidden
Popup LOV
Radiogroup
Select List
Text
Textarea
Checkbox Considerations
Checkboxes and radiobuttons
present unique challenges
If checkbox values are consistent
across all rows you can use the row
key for the value
Otherwise you need the value and a
way to associate it with the row key
Radiogroup Considerations
Radio buttons present even more
challenges
HTML radio input types are grouped
by NAME
Only one radio button per group can
be selected
Name
Red
Green
Blue
Element
Hidden
Display
Only
Radio
Radio
Radio
P_idx ->
Value
Primary
Key
Database
Value
Primary
Key
Primary
Key
Primary
Key
Compound Keys
ID
Name
Red
Green
Blue
Element
Hidden
Display
Only
Radio
Radio
Radio
P_idx ->
Database
Value
PK|RED
PK|GREEN
PK|BLUE
Value
Primary
Key (PK)
Compound Keys
DECLARE
l_key_arr
wwv_flow_global.vc_arr2;
BEGIN
FORALL i IN 1 .. apex_application.g_f01.COUNT
DELETE mytable
WHERE ID = apex_application.g_f01(i);
FOR x IN 1 .. apex_application.g_f03.COUNT
LOOP
l_key_arr :=
apex_util.string_to_table
(apex_application.g_f03(x), '|');
Triangulation Keys
Simple to create key structure
Flattens the checkbox or radio button
arrays to one array each
SELECT apex_item.hidden(50, ROWNUM) AS row_number
, apex_item.hidden(49, pk_column) AS pk
, apex_item.radiogroup(ROWNUM, radio_value,
selected_value, value_label) as radiobutton
FROM wherever
WHERE whatever
Triangulation Keys
Triangulation Keys
DECLARE
l_arrnum
VARCHAR2(50);
l_stmt
VARCHAR2(200);
l_arrval
VARCHAR2(100);
BEGIN
FOR i IN 1 .. apex_application.g_f49.COUNT
LOOP
-- build string to reference the array indicated
-- by the value in array 50
l_arrnum := 'apex_application.g_f'
|| LPAD(LTRIM(RTRIM(apex_application.g_f50(i))),2, '0');
-- build pl/sql block to extract value(s) as delimited string
l_stmt := 'BEGIN '
|| ' :l_arrval := apex_util.table_to_string('
|| l_arrnum -- eg apex_application.g_f10
|| ', '':''); END;';
-- run block using out bind value
EXECUTE IMMEDIATE l_stmt USING OUT l_arrval;
save_response(:g_resp_id, apex_application.g_f49(i), l_arrval);
END LOOP;
END;
Checkbox Function
APEX_ITEM.CHECKBOX
Arguments:
p_idx = The form element name, e.g. 1 equals f01, 2 equals
f02, etc.
Typically the p_idx argument is constant for a given column.
p_value = When checked return this value
p_attributes = Custom HTML arguments added to the HTML
input type of checkbox.
p_checked_values = Colon (by default delimted list of values
p_checked_values_delimitor = Defaults to a colon ":" and is
used to pass multiple values in one string.
p_item_id = Will set the ID of the item to this value (id="...").
Must be unique! Try concatenating some string with
rownum. Required for 508 compliance
p_item_label = Creates an invisible label for an item. Used
for Section 508 Compliance. Class is hideMe508.
Some Limitations
Submitted data is not stored
No easy way to validate
MRU Checksum Error
create_collection (delete_collection)
create_or_truncate_collection
add_member
update_member
create_collection_from_query
create_collection_from_query_b
Report Source
, apex_item.radiogroup(ROWNUM, radio_value,
selected_value, value_label) as radiobutton
wwv_flow_collections
FROM wwv_flow_collections
WHERE collection_name = :l_collection
Column
Attributes
APEX_ITEM API
Tables & Views
wwv_flow_collections
wwv_flow.accept
Page Process
Validation Errors
Report query outer joined to collection
Submit process to
CREATE_OR_TRUNCATE_COLLECTION
Submit process finds validation errors and stores
information in collection
Submit process to update data for records without
validation error
Branch to same page and report query will access any
error messages in collection (or just limit it to those with
errors if errors are present)