0 Replies Latest reply: Jul 12, 2012 1:37 AM by EEG RSS

    Dynamically Place Tabular Form Into Session State

    EEG
      Hello.

      I'm using Apex 4.1.0 on Oracle 10.2.0.5 and Oracle App Server 10g (mod_plsql).

      I manually created a tabular form (and so, not wizard created) using the following plsql code:
      declare
      
        v_sql             varchar2(32767);
        v_choice_order    integer;
      
      begin
      
        v_sql    := null;
      
        ----
      
        if ( :P86_RADIO_ADD_ROW = '1' ) then
      
          if ( apex_collection.collection_member_count('COL_RADIO_CHOICES') > 0 ) then
            begin
            select max(to_number(c014)) + 1
              into v_choice_order
              from apex_collections
             where collection_name = 'COL_RADIO_CHOICES';
            exception
              when no_data_found then
                v_choice_order := 1;
            end;
          else
             v_choice_order := 1;
          end if;
      
          apex_collection.add_member(p_collection_name => 'COL_RADIO_CHOICES',
                                     p_c001            => null,
                                     p_c002            => null,
                                     p_c003            => null,
                                     p_c004            => null,
                                     p_c005            => null,
                                     p_c006            => null,
                                     p_c007            => null,
                                     p_c008            => null,
                                     p_c009            => null,
                                     p_c010            => null,
                                     p_c011            => null,
                                     p_c012            => null,
                                     p_c013            => null,
                                     p_c014            => to_char(v_choice_order),
                                     p_c015            => 'Y',
                                     p_c016            => null,
                                     p_c017            => null,
                                     p_c018            => null,
                                     p_c019            => null,
                                     p_c020            => 'EMPTY',
                                     p_generate_md5    => 'YES');
      
          commit;
      
        end if;  -- if ( :P86_RADIO_ADD_ROW = '1' ) then
      
        ----
      
        v_sql :=
        'select apex_item.checkbox2 (10,
                                     seq_id,
                                     case when (c020 in (''NEW'',''EMPTY'')) then ''onclick="radio_highlight_row(this,'' || ''#ROWNUM#'' || '')"'' else null end,
                                     null,
                                     '':'',
                                     ''f10_'' || ''#ROWNUM#''
                                    ) delete_row,
                                    apex_item.hidden (11, seq_id) || apex_item.text (12, c006, 30, 30, ''style="width:140px"'', ''f12_'' || ''#ROWNUM#'') display_text,
                                    apex_item.checkbox2 (13, ''#ROWNUM#'', null, decode(c007,''CHECKED'', ''#ROWNUM#''),'':'',''f13_'' || ''#ROWNUM#'') defaulted,
                                    apex_item.hidden (14, c014) || apex_item.hidden (15, c020) || apex_item.select_list(16, c015, ''Active;Y,InActive;N'', ''style="color:darkred;"'', ''NO'', ''%NULL%'', ''%'', ''f16_'' || ''#ROWNUM#'', NULL, ''NO'') active_status
                               from apex_collections
                              where collection_name = ''COL_RADIO_CHOICES''
                                and c020 != ''DELETED''
                              order by to_number(c014) asc
         ';
      
        ----
      
        return v_sql;
      
      end;
      I manage the addition, removal, and saving of changes via Apex collections together with the g_fxx arrays associated with the columns in the above report code.

      Each time users click buttons like "Add Row", "Remove Row", and "Apply Changes", plsql processes are run via page submits.

      All this works ok.

      Still, I'm not happy with it. There are too many page submits going on.

      I know how to use Dynamic Actions to place individual page items into session state.

      Indeed, I found on the web how someone uses a simple "On Change" Dynamic Action in which the following plsql code is run
      begin
      null;
      end;
      I include the individual page items in the field "Page Items To Submit" field.

      With this Dynamic Action in place, simply typing anything in these page items immediately paces the text into session state. No buttons to click or any other triggering element to rely on.

      Is there some way to do the same sort of automatic "put into session state" with a manually created tabular form?

      I'm thinking this can be done via JQuery selectors but cannot wrap my mind around how to go about doing this.

      My goal is to minimize the number of page submits being done by my code each time users click one of my buttons or select a checkbox in my tabular form.

      Thank you for any advice or example code.

      Elie