Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [solved] Adding default date to calendar control [code]

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[solved] Adding default date to calendar control [code]
 Login/Join
 
Virtuoso
posted
We have a call to retrofit a number of existing MR launch pages. They all were developed for 7.6.5 or later. All have an "as-of" date parameter, a calendar control (text field coupled with a calendar icon which brings up an IBI standard-issue calendar dialog box).

At present, the default value is blank. We want to make the default value (the mm/dd/yyyy text value initially displayed) reflect the most recent financial "close" date.

The question is how this can be retrofitted with minimal disturbance of existing html code?



It occurred to me that one could have a fex retrieve the value into an amper variable, imbed the htm file by means of -HTMLFORM, and change the value='' in the htm file into a !IBI reference -- effectively pre-seeding the html with the dynamically determined value.

-- But that would mean converting links to the launch-page into links to run the fex. And who says that nothing will break (are &'s imbedded in the launch-page guaranteed to work when imbedded into a fex through "-HTMLFORM pagename")? And in terms of over-all architecture, that's too radical a change to impose on the application.


So instead of pushing the value into the html code, it looks like we need to pull in the value after the page is loaded.

I have tried composing a page with a calendar control, or even a simple text input control, with value to be be populated dynamically by a fex call (as we do for dropdown lists). I could not get that to work. If there is a way to accomplish that in Composer, I would appreciate if someone can provide step-by-step instructions. Once I can create a fresh calendar control with that behavior, I will deal with retrofitting existing launch-pages.

Assuming the GUI provides a means to call a fex, would the fex in that case pass back the value as a one-row xml document, analogous to the way dropdowns are populated?

This message has been edited. Last edited by: j.gross,


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
Jack,

I do something very simliar to get the default (or last viewed) code for pre-population of a combo. I use an adhoc fex generated within the JavaScript to get back the value from a table as required and then isoklate the value before placing it into the control as necessary. Because the target control is a chained combo box, I then force the chaining to repopulate from that control downwards - you probably wont need that but I left it in because it can be a useful piece of info.

The code I've placed below is a modified version to give you something relevant to the sample CAR table, but it does show the principle.

The JS is called upon page / form load. I usually use a slight delay to the call to allow for the controls to be created etc by IBI JavaScript routines. Just add something like setTimeout('get_country()',150); to the window_onload function.

Good luck

T

function get_country() {
  var requestPref = getWFScriptName() + '?IBIMR_action=MR_GET_DOMAINS&IBIMR_returntype=xml';
  requestPref += "&IBIMR_Random=" + Math.random();
  var UserInfoXml = getXml(requestPref);
  var name="JAGUAR";
  if(UserInfoXml) {
    var pattern = "//MR_GET_USER_GROUPS";
    var pattern1 = "//CURRENT_USER";
    var node = null;
    if(isIEvar) {
    node = UserInfoXml.selectSingleNode(pattern1);
    } else {
      xpathResult = UserInfoXml.evaluate(pattern1, UserInfoXml, null, 0, null);
      node = xpathResult.iterateNext();
    }
    if(node) {
      var name = node.getAttribute("name").toUpperCase();
      var request =  getWFScriptName() + "?IBIC_server=EDASERVE&IBIAPP_app=ibisamp&IBIF_adhocfex=";
      request += "TABLE FILE CAR%0D%0APRINT COUNTRY%0D%0A";
      request += "WHERE CAR EQ '"+name+"'%0D%0AON TABLE PCHOLD FORMAT XML%0D%0AEND";
      request += "&IBIMR_Random=" + Math.random();
      var ctryXml = getXml(request);
      if(ctryXml) {
        var pattern = "/fxf/report/table/tr/td[@colnum='c0' or @colnum='c1']";
        if(isIEvar) {
          xmlctry = ctryXml.selectSingleNode(pattern);
        } else {
          xpathResult = ctryXml.evaluate(pattern, ctryXml, null, 0, null);
          xmlctry = xpathResult.iterateNext();
        }
      }
      country_id = "KOREA";
      if (xmlctry.firstChild.nodeValue != null && xmlctry.firstChild.nodeValue != undefined) {
        country_id = xmlctry.firstChild.nodeValue;
      }
// Now align the current selected item in combobox1
      ctry_cntl = document.getElementById("combobox1");
      for (i=0; i<ctry_cntl.length; i++) {
        if (ctry_cntl[i].value == proj_id) {
          ctry_cntl.selectedIndex = i;
          i=ctry_cntl.length;
        }
      }
      DoResetDownChainControls(document.getElementById("combobox1"));
    }
  }
}



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
Thanks, I'll look it over.

One observation -- in the TABLE request you compose, you could save yourself the trouble (and clutter) of adding the crlf's (%0D%0A). The only portion of the TABLE request that needs to be on a separate line is END.

In my case, the fex to retrieve the default value needs no parameters, to I would run a stored fex rather than an ad-hoc.

This message has been edited. Last edited by: j.gross,


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
Jack,

I am aware of that ... but then I'm fussy WinkRazzer

T
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
I whittled the function down to this:
  
function get_close_date() {
    var closeDate = new Object();
    closeDate.value="          ";
    closeDate.request =  getWFScriptName() + "?IBIC_server=EDASERVE&IBIAPP_app=grants_app&IBIF_adhocfex=";
    closeDate.request += "EX grants_close_date_xml";
    closeDate.request += "&IBIMR_Random=" + Math.random();
    closeDate.dateXml = getXml(closeDate.request);
    if(closeDate.dateXml) {
      closeDate.pattern = "/fxf/report/table/tr/td[@colnum='c0' or @colnum='c1']";
      if(isIEvar) {
        closeDate.datenode = closeDate.dateXml.selectSingleNode(closeDate.pattern);
      } else {
        closeDate.xpathResult = closeDate.dateXml.evaluate(closeDate.pattern, closeDate.dateXml, null, 0, null);
        closeDate.datenode = closeDate.xpathResult.iterateNext();
      }
    }
    if (closeDate.datenode.firstChild.nodeValue != null && closeDate.datenode.firstChild.nodeValue != undefined) {
      closeDate.value = closeDate.datenode.firstChild.nodeValue;
    }
      close_date = closeDate.value;
alert("close date: " + close_date );
      return close_date ;


It operates -- I am able get the fex to run, return xml, and capture and display the value ... But where do I stuff it?

The calendar control is no standard-issue HTML < INPUT > or < SELECT >.
  
<INPUT 
 id=calendar1 
 style="Z-INDEX: 12; LEFT: 120px; WIDTH: 70px; POSITION: absolute; TOP: 50px; HEIGHT: 22px" 
 tabIndex=17 
 maxLength=10 
 accept=0 
 size=10 
 name=REPDATE 
 sourcetype="typeMaster" 
 datatype="0" 
 datasource 
 operation 
 addalloption="0" 
 elementtype="14" 
 calendardata="0/0/-10;0/0/0" 
 calendardatatype="1" 
 boundtovariable="1" 
 selectedvalue=" " 
 ibiformat="MDYY"
> 


To boot, ibirls comes in 3 versions, with different numbers of args to getXml. One hopes there's capatibility compatibility when the newer versions' addtional formal arguments are omitted ...

This message has been edited. Last edited by: j.gross,


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
Jack,

As you say, if there's compatibility then the object(s) that you need to "stuff" with the date will be the one(s) where you have an elementtype of "editcalendar" or "14".

However, as you will find out, these are dynamic controls set up within the IB JavaScript routines, so you have to hunt the DOM to get them. This part, to read the DOM, is quite stright forward -

// This function is called on form loading and pulls a collection of calendar controls
// before calling the function to set the date value
    function PrepDates() {
      for (i=0;i<document.all.length;i++) {
        if (document.all(i).elementtype == "editcalendar" || document.all(i).elementtype == "14") {
           this.displayElement = document.getElementById (document.all(i).id);
// This is the call to your date setting function
           SetDate(document.all(i).id);
        }
      }
    }

Good luck!

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
Just throwing out ideas here, which you may have already dismissed.... Could you run a FEX from edasprof.prf to put the financial close date into a global (&&) variable, or (if it changes infrequently and RC is running at your site) schedule a task in ReportCaster to write it to a text file and -READ it into a global variable in edasprof? Then putting the value in your launch page's text box would hopefully require only a simple JS assignment statement using the global variable.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Virtuoso
posted Hide Post
Here's what I wound up with:

//Begin function window_onload
function window_onload() {

UpdateData();

// TODO: Add your event handler code here
//add onInitialUpdate() function to make changes before initial run of the reports

//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* set default value for REPDATE parameter
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 
  if ( document.forms[0].REPDATE && 
       document.forms[0].REPDATE.elementtype && 
       document.forms[0].REPDATE.elementtype=='14') 
    {
      setTimeout('set_default_repdate(document.forms[0].REPDATE)',100);
    }
}
function set_default_repdate(repdate) {
    var closeDate = new Object();
    closeDate.request =  getWFScriptName() + "?IBIC_server=EDASERVE";
    closeDate.request += "&IBIAPP_app=grants_app&IBIF_ex=grants_app/grants_close_date_xml";
    closeDate.request += "&IBIMR_Random=" + Math.random();
    closeDate.dateXml = getXml(closeDate.request);
    if(closeDate.dateXml) {
      closeDate.pattern = "/fxf/report/table/tr/td[@colnum='c0' or @colnum='c1']";
      if(isIEvar) {
        closeDate.datenode = closeDate.dateXml.selectSingleNode(closeDate.pattern);
      } else {
        closeDate.xpathResult = closeDate.dateXml.evaluate(closeDate.pattern, closeDate.dateXml, null, 0, null);
        closeDate.datenode = closeDate.xpathResult.iterateNext();
      }
    }
    if (closeDate.datenode.firstChild.nodeValue != null && closeDate.datenode.firstChild.nodeValue != undefined) {
      closeDate.value = closeDate.datenode.firstChild.nodeValue;
    } else {
      closeDate.value="          ";
    }
  repdate.value=closeDate.value;
  return repdate.value
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* 
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


}
//End function window_onload


I made the insertion a contiguous block of code -- which includes my addition to the body of the window_onload() function, and its closing brace; then my own set_default_repdate() function, which is closed by the brace in the original code (the one that originally closed window_onload() ).

This message has been edited. Last edited by: j.gross,


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
Dan, we do have a bunch of && in our edasprof, as you suggest, trouble with this particular one is that , although it advances monthly, the timing of that advance is erratic.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [solved] Adding default date to calendar control [code]

Copyright © 1996-2020 Information Builders