2 Replies Latest reply: Nov 1, 2012 11:42 AM by bookert RSS

    Trouble setting the session state of a select item.

    bookert
      Hi,

      I have a requirement whereby I need to change the session state of a select list item in my form without the need to submit. I am using Application Express 4.1.0.00.32. I thought this would be straight forward using a dynamic action or javascript and calling an on demand process for example.

      P1_MY_SELECT onchange="set_option();"

      function set_option() {
      var l_option=$f_SelectValue('P1_MY_SELECT');
      alert( 'My new value is ' + l_option );

      // ON DEMAND Set the new session state value
      var lRequest = new apex.ajax.ondemand
      ('SET_P1_MY_SELECT',function()
      {  /* start the return function */
      var l_s = p.readyState;
      if(l_s == 1||l_s == 2||l_s == 3)
      {}
      else if(l_s == 4)
      { gReturn = p.responseText;
           (gReturn)?json_SetItems(gReturn):null;
      }
      else{return false;}
      /* end the return function */
      }
      );
      lRequest.ajax.addParam('x01', l_option );
      lRequest._get()

      };

      My on demand application process

      DECLARE
      l_options varchar2(2000) := wwv_flow.g_x01;
      BEGIN
      APEX_UTIL.SET_SESSION_STATE('P1_MY_SELECT',l_options);
      apex_util.json_from_items('P1_MY_SELECT');
      END;

      Is there a better method to set the session state of my P1_MY_SELECT other than what I am doing as above or can you tell me why the session state of P1_MY_SELECT is not changed?

      Thanks.

      Edited by: 968358 on 01-Nov-2012 08:40