This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 31st, when you will be able to use this site as normal.

    Forum Stats

  • 3,890,899 Users
  • 2,269,649 Discussions
  • 7,916,821 Comments

Discussions

Form Fields from HTP.P are not submitting with the rest of the APEX Items on the page...

bostonmacosx
bostonmacosx Member Posts: 177 Blue Ribbon

Hello there.


I'm trying to create a dynamic form with the following PLSQL....When I click the submit button I get NO values from these form elelments. It appears that the entire page is "wrapped" in a form tag. The checkboxes and text input field draw fine but they are never SUBMITTED....


form action="wwv_flow.accept" method="post" name="wwv_flow" id="wwvFlowForm" novalidate="" autocomplete="off" _lpchecked="1"


------PLSQL CODE

DECLARE

 v_group_name VARCHAR2(100);

 v_id NUMBER;

 v_description VARCHAR2(100);

 v_label VARCHAR2(500);

  

  CURSOR get_groups IS

   SELECT DISTINCT group_name

   FROM queries;


  /* Second cursor */

  CURSOR get_details IS

   SELECT id,description,label from queries where group_name = v_group_name

   order by id ;

   

   

BEGIN

 open get_groups;

  

  LOOP

   fetch get_groups into v_group_name;

   exit when get_groups%notfound;

     htp.p('<DIV>'||v_group_name||'</DIV>');


   open get_details;

    LOOP

     fetch get_details into v_id,v_description,v_label;

           exit when get_details%notfound;

      htp.p(APEX_ITEM.CHECKBOX(v_id,v_id,'CHECKED'));

       

      htp.p(v_id);

      htp.p(v_description);

      htp.p(v_label);

     END LOOP;

   close get_details;

 END LOOP;

 close get_groups;

 htp.p(APEX_ITEM.TEXT(10,'test'));



EXCEPTION

  WHEN OTHERS THEN

   raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);


END;

Tagged:

Best Answer

  • Joe Upshaw
    Joe Upshaw Member Posts: 983 Silver Badge
    Answer ✓

    I don't think think items created on the fly will be able to participate in the built-in page submission. As they are dynamically created, youd have to manage getting them set in the session yourself, "manually". This is just the price you pay for the flexibility of dynamically generating the items instead of creating them declaratively. You have a couple of options here...

    You could not create these dynamically (Best Answer). Looks like you want to create a bunch of checkboxes for groups based on a query....ok. Just create a "Checkbox Group" page item and use a query, i.e. List of Values with a SQL Query, to populate it. Based on your sample code, I'm just not sure I see why you'd ever need to do this but, maybe the example was simplified just to explain the problem.

    So, if you really must use dynamic items, you have to set them in the session yourself, manually. You will need a button to perform that submit which will fire an on Submit process. In that process, you can use the APEX_APPLICATION GF01 property to get a reference to, and operate on, your dynamically created items. In this example, we're doing a DELETE.

    FOR I in 1..APEX_APPLICATION.G_F01.COUNT LOOP
        DELETE FROM queries WHERE id = to_number(APEX_APPLICATION.G_F01(i));
    END LOOP;
    

    NOTE: APEX_ITEM is deprecated. In each release Oracle threatens more strongly to yank it. I'm not sure how they'll do this without some suitable replacement but, be aware that you may be painting yourself into a corner for future releases.


Answers

  • Joe Upshaw
    Joe Upshaw Member Posts: 983 Silver Badge
    Answer ✓

    I don't think think items created on the fly will be able to participate in the built-in page submission. As they are dynamically created, youd have to manage getting them set in the session yourself, "manually". This is just the price you pay for the flexibility of dynamically generating the items instead of creating them declaratively. You have a couple of options here...

    You could not create these dynamically (Best Answer). Looks like you want to create a bunch of checkboxes for groups based on a query....ok. Just create a "Checkbox Group" page item and use a query, i.e. List of Values with a SQL Query, to populate it. Based on your sample code, I'm just not sure I see why you'd ever need to do this but, maybe the example was simplified just to explain the problem.

    So, if you really must use dynamic items, you have to set them in the session yourself, manually. You will need a button to perform that submit which will fire an on Submit process. In that process, you can use the APEX_APPLICATION GF01 property to get a reference to, and operate on, your dynamically created items. In this example, we're doing a DELETE.

    FOR I in 1..APEX_APPLICATION.G_F01.COUNT LOOP
        DELETE FROM queries WHERE id = to_number(APEX_APPLICATION.G_F01(i));
    END LOOP;
    

    NOTE: APEX_ITEM is deprecated. In each release Oracle threatens more strongly to yank it. I'm not sure how they'll do this without some suitable replacement but, be aware that you may be painting yourself into a corner for future releases.


  • bostonmacosx
    bostonmacosx Member Posts: 177 Blue Ribbon

    Hello there.

    I was able to write the APEX_APPLICATION.G_F01 into a collection on page submit...therefore it is accessible.
    
    Thanks fo the help