Creating the Refresh Function

How to:

This section has an example of JavaScript that you can use to pass current selections from the HTML page to the BI Portal and to have the BI Portal refresh all components, except itself.


Top of page

x
Procedure: How to Create the Refresh Function
  1. In Developer Studio, in the Properties and settings dialog box, open the Designer tab.
  2. On the form, click the Run button. Do not click the Developer Studio Run button.
  3. On the right side of the form, switch the panel from Properties to Events at the bottom using the tabs.
  4. Find the onclick event and click the ellipsis at the end of that field.

    This action switches you to the Embedded JavaScript section and creates a function called form1Submit_onclick.

  5. In the function, create a call to the refreshReports function you are about to write. The completed form1Submit_onclick function is:
    //Begin function form1Submit_onclick
    function form1Submit_onclick(ctrl) {
      refreshReports();
    }
    //End function form1Submit_onclick
  6. Below that function, place the code to create the refreshReports function.
    function refreshReports(){
      var name = this.window.name;
      parent.BipIframeInterface.setAllAmpersValues(name, IbComposer_getAllAmpersValues());
      parent.BipIframeInterface.refresh(parent.BipIframeInterface.REFRESH_ALL_BUT_SELF , name);
    }

    Note: The third line wraps in this document, but it should appear on one line when you write it in HTML Composer.

    The three lines break down as follows:

    Line 1:

    var name = this.window.name;

    This line gets the current window name. This is needed as a parameter in Line 2.

    Line 2:

    parent.BipIframeInterface.setAllAmpersValues(name,IbComposer_getAllAmpersValues());

    This line must be broken down into two pieces.

    Piece 1:

    IbComposer_getAllAmpersValues())

    This function gets the currently selected values from all controls on an HTML Composer page as a single string that you can append to the end of a URL call.

    Piece 2:

    parent.BipIframeInterface.setAllAmpersValues

    This function takes the name of the current window and the string returned by Piece 1 (or any string you provide) and tells the portal to append this string at the end of any request it runs on all pages of the portal. There is an optional third parameter that can be sent to restrict the variables to a specific page. The following is an example of a page specific call.

    parent.BipIframeInterface.setAllAmpersValues(name, "&ampers…", parent.BipIframeInterface.AMPERS_PAGE_ONLY);

    Line 3:

    parent.BipIframeInterface.refresh(parent.BipIframeInterface.REFRESH_ALL_BUT_SELF , name);

    This function refreshes all frames on the portal that have already been run, except for the frame with the controls. This includes frames not on the currently visible page.

    To refresh just the current page:

    parent.BipIframeInterface.refresh(parent.BipIframeInterface.REFRESH_ALL_BUT_SELF,
       name, null, parent.BipIframeInterface.AMPERS_PAGE_ONLY);

    In the preceding examples, the first parameter to this function is always:

    BipIframeInterface.REFRESH_ALL_BUT_SELF

    There are other possibilities, shown in the following table.

    Refresh Type

    Parameter Value

    All Frames

    BipIframeInterface.REFRESH_ALL

    Just the current frame

    BipIframeInterface.REFRESH_SELF_ONLY

    All except the current frame

    BipIframeInterface.REFRESH_ALL_BUT_SELF

    Specific list (array) of frames

    BipIframeInterface.REFRESH_ARRAY

    Frames not in the list (array) of frames

    BipIframeInterface.REFRESH_ALL_BUT_ARRAY
  7. Below the window_onload function, add the onInitialUpdate function to pass default values to all reports.

    function onInitialUpdate(){refreshReports();}

    Note: This function provides default values for any reports that might not have them specified. After the form loads the controls, the function is called and the default value from the form is sent to all reports.

    The complete Embedded Java Script tab is shown in the following image.

    Embedded Script tab

  8. Save the form.
  9. Exit Developer Studio.

WebFOCUS