This discussion is archived
9 Replies Latest reply: Dec 11, 2012 4:55 AM by Howard (... in Training) RSS

Place default checkbox value "in SESSION" on initial page load

Howard (... in Training) Pro
Currently Being Moderated
Oracle 11.2
Apex 4.1

Desire outcome: Chart renders on inital page load using default value of checkbox in query.

I have a checkbox with a default (checked) value. It shows checked when the page renders for the first time but the value is not in the SESSION state. I use this value in a query for a chart. I do not want to use a Submit button so I have a dynamic action submitting the value for the checkbox and the chart refreshes as desired when I check and uncheck the box.

I tried "Fire on Page Load" in the DA Execution Options, as well, but that caused a loop where the page renders and immmediately renders, and immediately renders, etc.

Is there a declarative solution that submits the current, in this case default, values when the page is loaded? I only need and want the default values used the first time the page is accessed. This is the initial page of the application but I need the same behavior on all pages for the separate checkbox selections found there.

May God Bless,
Howard
  • 1. Re: Place default checkbox value "in SESSION" on initial page load
    Mindmap Pro
    Currently Being Moderated
    Hello Howard,

    If you reproduce it on apex.oracle.com, it will be easier to help ....

    Regards,
    Fateh
  • 2. Re: Place default checkbox value "in SESSION" on initial page load
    714270 Pro
    Currently Being Moderated
    Make sure that the checkbox page item is included in the "Page Items to Submit" list of the chart query. What happens if you do not specify the default value for checkbox page item? Does it appear unchecked when the page loads? Also, did you try running the chart query in SQL commands to make sure it returns rows with the checkbox value specified? Btw, it would be really helpful if you can post an example in apex.oracle.com.
  • 3. Re: Place default checkbox value "in SESSION" on initial page load
    Howard (... in Training) Pro
    Currently Being Moderated
    Hello Rohit,
    Rohit Kapoor wrote:
    Make sure that the checkbox page item is included in the "Page Items to Submit" list of the chart query.
    I can try this but ... how will it help? The problem occurs before the submit. After submitting, there's no problem.
    What happens if you do not specify the default value for checkbox page item?
    The query won't find any data and I'll get "No data found." on the chart. That is what's happening now.
    Does it appear unchecked when the page loads?
    It appears checked because it's defaulted.
    Also, did you try running the chart query in SQL commands to make sure it returns rows with the checkbox value specified?
    The query works fine. In fact, there are multiple checkboxes and everything works fine -- except for the initial page load. The values just aren't set in the session on inital page load even though "checked" is the default and they appear checked on the screen. I think this is a feature. It probably affects radio buttons and similar constructs.

    Suggestion: It would be nice if there were a declarative construct to place page items into the session on initial load. Maybe there is but I haven't found it yet.
    Btw, it would be really helpful if you can post an example in apex.oracle.com.
    I know. I have a couple more things in the hopper and then I will put up an example.

    May God Bless,
    Howard
  • 4. Re: Place default checkbox value "in SESSION" on initial page load
    fac586 Guru
    Currently Being Moderated
    Howard (DBA in Training) wrote:

    The query works fine. In fact, there are multiple checkboxes and everything works fine -- except for the initial page load. The values just aren't set in the session on inital page load even though "checked" is the default and they appear checked on the screen. I think this is a feature. It probably affects radio buttons and similar constructs.
    It is a feature of all page items. The item Source and Default properties are used to set the item value rendered on the page, not in session state (you can see this by using the Session viewer when the page is first rendered). Values set in this way (or those the user has subsequently modified them to) are not set in session state until the page is submitted.
    Suggestion: It would be nice if there were a declarative construct to place page items into the session on initial load. Maybe there is but I haven't found it yet.
    There are two: Computations and Processes.
    May God Bless
    In line with the OTN Terms and Conditions, please do not use religious language in the forum. It is irrelevant and likely to cause offence to users who do not share your beliefs.
  • 5. Re: Place default checkbox value "in SESSION" on initial page load
    Howard (... in Training) Pro
    Currently Being Moderated
    fac586 wrote:
    >
    Hey fac586 -- good to hear from you.

    > It is a feature of all page items.
    Got to love those features!
    Suggestion: It would be nice if there were a declarative construct to place page items into the session on initial load. Maybe there is but I haven't found it yet.

    There are two: Computations and Processes.
    Well, I'd like to try those but when I created a simple example in APEX 4.2, I got twice what I wanted. Two sets of checkboxes instead of one. So, my first problem would seem to be to get that straightened out. Without a default value, I get the two checkboxes I'm asking for with "A;a,B;b". But when I add a default, I get an addiitonal checkbox for each default value!!! The first set is unchecked and the default set is checked. You can see it here: http://apex.oracle.com/pls/apex/f?p=21997:3 Login Dever / Ima9Dever

    So anyone/everyone: What have I select to cause these to be doubled?
    May God Bless
    In line with the OTN Terms and Conditions, please do not use religious language in the forum. It is irrelevant and likely to cause offence to users who do not share your beliefs.
    I thought I read the terms over carefully. Is that one of the 21 sections.

    What about "Blessings" or "Regards". I know being cordial is irrevelevant but it kind of a nice thing to say.

    Howard
  • 6. Re: Place default checkbox value "in SESSION" on initial page load
    fac586 Guru
    Currently Being Moderated
    Howard (DBA in Training) wrote:

    Well, I'd like to try those but when I created a simple example in APEX 4.2, I got twice what I wanted. Two sets of checkboxes instead of one. So, my first problem would seem to be to get that straightened out. Without a default value, I get the two checkboxes I'm asking for with "A;a,B;b". But when I add a default, I get an addiitonal checkbox for each default value!!! The first set is unchecked and the default set is checked. You can see it here: http://apex.oracle.com/pls/apex/f?p=21997:3 Login Dever / Ima9Dever
    What default value are you using?

    If I create a checkbox item with static values:
    A;a,B;b
    and Default Value:
    a:b
    then I get the 2 A/B checkboxes, both checked.

    If I remove the Default Value and add a Before Header page computation for the item with static assignment to
    a:b
    I get the 2 A/B checkboxes, both checked, and the value is set in session state.
  • 7. Re: Place default checkbox value "in SESSION" on initial page load
    Howard (... in Training) Pro
    Currently Being Moderated
    fac586 wrote:
    Howard (DBA in Training) wrote:

    Well, I'd like to try those but when I created a simple example in APEX 4.2, I got twice what I wanted. Two sets of checkboxes instead of one. So, my first problem would seem to be to get that straightened out. Without a default value, I get the two checkboxes I'm asking for with "A;a,B;b". But when I add a default, I get an addiitonal checkbox for each default value!!! The first set is unchecked and the default set is checked. You can see it here: http://apex.oracle.com/pls/apex/f?p=21997:3 Login Dever / Ima9Dever
    What default value are you using?

    If I create a checkbox item with static values:
    A;a,B;b
    and Default Value:
    a:b
    then I get the 2 A/B checkboxes, both checked.
     ==== ) How do you keep it from setting/resetting these values each time the 
    page is rendered?  The need is to do it only the very first time?  ( ====
    >
    If I remove the Default Value and add a Before Header page computation for the item with static assignment to
    a:b
    I get the 2 A/B checkboxes, both checked, and the value is set in session state.
    If you log in here, you can see it up close and personal!
    http://apex.oracle.com/pls/apex/f?p=21997:3 Login: Dever / Ima9Dever

    Oh, I'm off to a relative's unspecified holiday concert. Back in a couple of hours.

    *********************
    Howard

    Edited by: Howard (DBA in Training) on Dec 10, 2012 5:58 PM
  • 8. Re: Place default checkbox value "in SESSION" on initial page load
    fac586 Guru
    Currently Being Moderated
    Howard (DBA in Training) wrote:
    If I remove the Default Value and add a Before Header page computation for the item with static assignment to
    a:b
    I get the 2 A/B checkboxes, both checked, and the value is set in session state.
    If you log in here, you can see it up close and personal!
    http://apex.oracle.com/pls/apex/f?p=21997:3 Login: Dever / Ima9Dever
    The Default Value colon-delimited string must contain the checkbox values, not the labels. In a static LOV the checkbox options are specified as <tt>label;value</tt> pairs. Thus in your checkbox LOV the labels are A/B, whilst the values are a/b. The values are case-sensitive.

    The Default Value should therefore be:
    a:b
    whereas you've specified:
    A:B
    With the checkbox item LOV Display Extra Values property set to Yes, APEX displays these extra values that are not included in the LOV definition as additional checkboxes. You can see this if you inspect the rendered checkbox elements in the HTML source:
    <input type="checkbox" id="P3_CHECKBOX_0" name="p_v01" value="a">
    ...
    <input type="checkbox" id="P3_CHECKBOX_1" name="p_v01" value="b">
    ...
    <input type="checkbox" id="P3_CHECKBOX_2" name="p_v01" value="A" checked="checked">
    ...
    <input type="checkbox" id="P3_CHECKBOX_3" name="p_v01" value="B" checked="checked">
    You get the a/b values defined in the LOV, plus the extra A/B values the LOV knows nothing about.
     ==== ) How do you keep it from setting/resetting these values each time the 
    page is rendered?  The need is to do it only the very first time?  ( ====
    Put a Value of Item / Column in Expression 1 Is NULL condition on the Computation. Problem then is that the computation will be run if the user can [legitimately] deselect all of the checkboxes, either leaving you back where you started, or requiring the use of a further item to flag whether it is the really "the very first time" (which I find intellectually deeply unsatisfactory). This may be a sign that the control should really be a radio group that always has one option set, rather than a check box.
  • 9. Re: Place default checkbox value "in SESSION" on initial page load
    Howard (... in Training) Pro
    Currently Being Moderated
    Wow. Thanks for seeing the problem with the default values.
    fac586 wrote:
    Howard (DBA in Training) wrote:
     ==== ) How do you keep it from setting/resetting these values each time the 
    page is rendered?  The need is to do it only the very first time?  ( ====
    Put a Value of Item / Column in Expression 1 Is NULL condition on the Computation. Problem then is that the computation will be run if the user can [legitimately] deselect all of the checkboxes, either leaving you back where you started, or requiring the use of a further item to flag whether it is the really "the very first time" (which I find intellectually deeply unsatisfactory). This may be a sign that the control should really be a radio group that always has one option set, rather than a check box.
    Problem then is that ... 
    Yes, of course, that's the problem. To me, the natural use of checkboxes is that they would be checked and unchecked. In fact, I have a checkbox group of four independent options the user may wish to check / uncheck. So, the condition I need to test is: "Is this the first time the page is being displayed?"

    There must be some standard APEX solution for this. It has to come up all the time. I assume I can kludge it with a first-time flag. I was just hoping APEX had a nice declarative solution for testing first-time conditions. Oh, well.

    ***************
    Howard

Legend

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