This discussion is archived
8 Replies Latest reply: May 1, 2013 6:47 AM by Howard (... in Training) RSS

Using APEX_UTIL.SET_SESSION_STATE to put an item value in Session State?

Howard (... in Training) Pro
Currently Being Moderated
Objective: Refresh a region, but not the entire page, where the region has a query based on the value of a page item the user has selected. I (think) I (would) have the region refresh working fine but the page item the query uses is not in Session State!

Current Question: I have a procedure (APEX_UTIL.SET_SESSION_STATE) to place a value the user enters into Session State but how do I get that value in the first place?

What I have in the region:
:P23_SELECT_RUN_DT (date picker)
Rows retrieved based on this date picker. And initially, the query retrieves all rows because :P23_SELECT_RUN_DT (date picker) is null.

I'm trying to follow {message:id=9781139},
I have added a DA (event: change) with the following PL/SQL:
BEGIN
    APEX_UTIL.SET_SESSION_STATE('P23_SELECT_RUN_DT','???');
END;
But how do I specify the value to be used is from the date picker? I can’t use :P23_SELECT_RUN_DT; it's null.

I've added this :P23_SELECT_RUN_DT item to an example I'm already working:
WS: APEX_EXAMPLES_01
USER: demo
PW: demo
Application: 991203 - BPR_991203 Page 23 (Tab: Master 3)
Click the edit pencil after "ProgramName 1" to populate all three regions. The date picker is in the third region.

Is this the approach to use? Can someone suggest a more straight-forward way to accomplish this?

Thanks in advance,
Howard
  • 1. Re: Using APEX_UTIL.SET_SESSION_STATE to put an item value in Session State?
    fac586 Guru
    Currently Being Moderated
    Howard (... in Training) wrote:

    Is this the approach to use?
    No.
    Can someone suggest a more straight-forward way to accomplish this?
    Use the Page Items to Submit property in the Source section of the region definition.

    (I think that I have only had occasion to use APEX_UTIL.SET_SESSION_STATE twice in eight years: once when the name of the item had to be generated dynamically, and once when setting a number of values from within a package. Otherwise bind variable notation is all that is required.)
  • 2. Re: Using "Page Items to Submit" to put an item value in Session State?
    Howard (... in Training) Pro
    Currently Being Moderated
    Re my objective:
    Current Question: ... to place a value the user enters into Session State ... ?
    I thought maybe that would work. I aded P23_SELECT_RUN_DT to "Page Items to Submit". I removed the former DAs. Then I added a region refresh to the date picker thinking that the :P23_SELECT_RUN_DT value would be submitted each time the date picker changed. No joy. The newly selected value is not placed in Session State.

    ???
    Howard
  • 3. Re: Using "Page Items to Submit" to put an item value in Session State?
    Howard (... in Training) Pro
    Currently Being Moderated
    Along the way, I tried WannaRock's suggestion {message:id=10994029}. But could not get that to work either so now have removed that code.

    Howard
  • 4. Re: Using "Page Items to Submit" to put an item value in Session State?
    fac586 Guru
    Currently Being Moderated
    Howard (... in Training) wrote:
    Re my objective:
    Current Question: ... to place a value the user enters into Session State ... ?
    I thought maybe that would work. I aded P23_SELECT_RUN_DT to "Page Items to Submit". I removed the former DAs. Then I added a region refresh to the date picker thinking that the :P23_SELECT_RUN_DT value would be submitted each time the date picker changed. No joy. The newly selected value is not placed in Session State.

    ???
    You're going to hate this :D (although I admit it is über obscure—I was rapidly running out of ideas when I noticed it...)

    The problem was the static region ID <tt>BPR_RUN Detail</tt>. This is invalid as HTML ID attributes cannot contain any space characters. I don't know exactly why the presence of the verboten space discombobulates APEX and/or jQuery so comprehensively, and I'm not venturing into the debugger to attempt to find out. I'll simply point to it as another reason to show some respect for HTML and use standards-compliant mark-up.
  • 5. Re: Using "Page Items to Submit" to put an item value in Session State?
    Howard (... in Training) Pro
    Currently Being Moderated
    Hate it. Naw. I was going to check if that was a problem but hadn't the time yet.

    Standard markup? Hmm. Is there an assumption here that APEX novices can more than just spell HTML. (Spelling? Yes I can forward and backwards but little else than bracket tag end-bracket ... bracket /tag end-bracket.) Is HTML suppose to be an APEX prerequisite? <removes tongue from cheek and steals away.}

    Thanks,
    Howard

    Departing from my usual levity, let me ask: Where does it say the "experienced SQL and PL/SQL developer" needs to know any HTML, CSS, or ...?
    What is Oracle Application Express?
    Oracle Application Express (Oracle APEX) is a declarative, rapid web application development tool for the Oracle database. It is a fully supported, no cost option available with all editions of the Oracle database. Using only a web browser, you can develop and deploy professional applications that are both fast and secure.

    Whether you are an <B>experienced SQL and PL/SQL developer</B> or a power user used to writing reports, wizards allow you to quickly build Web applications on top of your Oracle database objects. <B>Enhancing and maintaining these applications is done using a declarative framework</B>, all of which increases your productivity.

    Oracle Application Express is database-centric and suited to building a vast array of applications. You can start with webifying a spreadsheet to facilitate collaboration or <B>dive right into extremely complex applications with numerous external interfaces</B> such as the Oracle Store. Because Oracle APEX resides within the Oracle Database and <B>can easily integrate</B> with authentication schemes (such as Oracle Access Manager, SSO, LDAP, etc.) <B>you can build secure applications that can scale</B> to meet your largest user communities.>
    Okay. It never says you'll be successful at it!

    Edited by: Howard (... in Training) on May 1, 2013 6:47 AM
  • 6. Re: Am I getting a region refresh?
    Howard (... in Training) Pro
    Currently Being Moderated
    To recap: Objective: Refresh a region, but not the entire page, where the region has a query based on the value of a page item the user has selected. I (think) I (would) have the region refresh working fine but the page item the query uses is not in Session State!

    Well, so much for: "I (think) I (would) have the region refresh working fine but the page item the query uses is not in Session State!". I can't tell if we've made process.

    Yes, the date picker (:P23_SELECT_RUN_DT) is now placed in Session State. This was accomplished thru "Page Items to Submit" and a DA region refresh based on the change event for the date picker. So -- if I understand what's going on, the region is being refreshed(?) but the region query is not being re-run. Is that possible?

    Here's the query:
    select 
    "ROWID",
    "PROC_NM",
    TO_CHAR(RUN_DT,'DD-Mon-YYYY HH24:MI:SS') RUN_DT1,
    "SITE",
    "START_TIME",
    "END_TIME",
    "STATUS"
    from "#OWNER#"."BPR_RUN"
    where "PROC_NM" = :P23_PROC_NM
      and "RUN_DT"  = NVL(TO_DATE(:P23_SELECT_RUN_DT,'DD-Mon-YY'),"RUN_DT")
    I assumed the query would be re-executed when the region refreshed. This does not seem to be happening. Or perhaps I'm not getting a refresh after all. I don't understand the conflicting evidence I see.

    ???
    Howard
  • 7. Re: Am I getting a region refresh?
    fac586 Guru
    Currently Being Moderated
    Howard (... in Training) wrote:
    To recap: Objective: Refresh a region, but not the entire page, where the region has a query based on the value of a page item the user has selected. I (think) I (would) have the region refresh working fine but the page item the query uses is not in Session State!

    Well, so much for: "I (think) I (would) have the region refresh working fine but the page item the query uses is not in Session State!". I can't tell if we've made process.

    Yes, the date picker (:P23_SELECT_RUN_DT) is now placed in Session State. This was accomplished thru "Page Items to Submit" and a DA region refresh based on the change event for the date picker. So -- if I understand what's going on, the region is being refreshed(?) but the region query is not being re-run. Is that possible?

    I assumed the query would be re-executed when the region refreshed. This does not seem to be happening. Or perhaps I'm not getting a refresh after all. I don't understand the conflicting evidence I see.
    The refresh action was running: the APXWGT requests are visible via Debug mode.

    However the Enable Partial Page Refresh report property was not enabled, so there were no hooks in the report region to enable the DA to replace the refreshed report data. Unlike standard reports, this option is set to "No" by default for tabular form reports. It needs to be set to "Yes" to enable DA refresh.

    Tabular Forms, Tabular Forms, tabular forms are just a mess of trouble...

    (And I can still break referential integrity in this setup by changing Proc Nm. Master/detail needs to use real, immutable PKs/FKs. ROWIDs just don't work for this.)
  • 8. Re: Am I getting a region refresh?
    Howard (... in Training) Pro
    Currently Being Moderated
    Thanks.

    I saw PPR in some discussions but can't get to blogs from here to check what they had to say. I thought there was a thread that said that PPR was "on" by default. No guarantee that thread is correct, of course. And no gaurantee that something I did had left it set one way or the other. I hunted in the Region Definition -- 3 times -- and could not find it so I assumed it was hidden by some other selection I had made. Now I see it's misplaced in the Report Attributes. Okay, I'll give that it's convenient to group it with the pagination attributes but it's actually a region "property," isn't it?

    Thanks again,
    Howard

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points