Focal Point
regarding UpdadeData() in html layout painter,please help

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8541001391

October 26, 2006, 09:24 AM
Balaji Gavini
regarding UpdadeData() in html layout painter,please help
hi,

this is the code i am using in html layout painter.In the window_onload funcction( method UpdateData()Winkis given by the webfocus itself which is used to populate the dropdown boxes from data source.After the statement i am calling the windowOnload() function to default my dropdowns.I have placed alert() statement in between the UpdateData() and windowOnload() methods.If i am removing that alert statement i am getting the error.I think some delay should happen between UpdateData() function and windowOnload() function. For that delay if i am using for loop even then it is giving the errror.only if i use alert() stmt it's not giving the error. Please help me in this regard.



<script type=text/javascript>

var g_orglevel = !IBI.AMP.P_ORGLEVEL; ;
var g_orgnumber = !IBI.AMP.P_ORGNUMBER; ;

var g_dist = 0;
if(g_orglevel == 4)
{

g_dist = !IBI.AMP.P_DIST; ;
}
var g_expctrid=' ';
var g_expctrgrp=' ';
var g_period=' ';
var g_fiscalyear=' ';
var g_dropdnname=' ';
var g_dropdnvalue=' ';

function window_onload() {
UpdateData();
alert();
windowOnload();
}

/* This function generates the report in the iframes of the page based on the parameters
* from the sccr_user_access.fex file and disable the dropdowns required based on the
* parameters
*/
function windowOnload(){


/*Making the ExpenseCenter drop down defaulted to Total Store*/
for(var i = 0; i < document.getElementById["cboExpCtr").length; i++){
if((document.getElementById("cboExpCtr").options[i].value) == "Total Store"){

document.getElementById("cboExpCtr").options[i].selected = true;
g_expctrgrp = document.getElementById("cboExpCtr").options[i].value ;
break;
}

}
g_period = getMonthId(document.getElementById("cbomonth").value);
g_fiscalyear = getFiscalYear(document.getElementById("cbomonth").value);

if(g_orglevel == 0){

g_dropdnvalue = g_orgnumber;
g_dropdnname = 'C';
var cmd = "WFServlet?IBIF_ex=sccr_landingpage_rpt&P_DEPT_ID="+g_orgnumber+"&P_DEPTNAME="+g_dropdnname+"&P_EXPCTR="+g_expctrid+"&P_EXPCTR_NAME="+g_expctrgrp+"&P_ORGLEVEL="+g_orglevel+"&P_ACCT_GRP_FOC="+P_ACCT_GRP_FOC+"&P_MONTH="+g_period+"&P_YEAR="+g_fiscalyear;
document.getElementById("reportFrame").src = cmd;
}

else if(g_orglevel == 1){

//Defaulting the dropdown values to the parameter g_orgnumber
for(var i = 0; i < document.getElementById["cboRegion").length; i++){

if(document.getElementById("cboRegion").options[i].value == g_orgnumber){

document.getElementById("cboRegion").options[i].selected = true;
break;
}
}

g_dropdnvalue = g_orgnumber;
g_dropdnname = 'R';
var cmd = "WFServlet?IBIF_ex=sccr_landingpage_rpt&P_DEPT_ID="+g_orgnumber+"&P_DEPTNAME="+g_dropdnname+"&P_EXPCTR="+g_expctrid+"&P_EXPCTR_NAME="+g_expctrgrp+"&P_ORGLEVEL="+g_orglevel+"&P_MONTH="+g_period+"&P_YEAR="+g_fiscalyear;
document.getElementById("reportFrame").src=cmd;
}
else if(g_orglevel == 2){


// Defaulting the dropdown values to the parameter g_orgnumber
for(var i = 0; i < document.getElementById["cboSpoke").length; i++){

if(document.getElementById("cboSpoke").options[i].value == g_orgnumber){

document.getElementById("cboSpoke").options[i].selected=true;
break;
}
}
g_dropdnvalue = g_orgnumber;
g_dropdnname = 'G';
var cmd = "WFServlet?IBIF_ex=sccr_landingpage_rpt&P_DEPT_ID="+g_orgnumber+"&P_DEPTNAME="+g_dropdnname+"&P_EXPCTR="+g_expctrid+"&P_EXPCTR_NAME="+g_expctrgrp+"&P_ORGLEVEL="+g_orglevel+"&P_MONTH="+g_period+"&P_YEAR="+g_fiscalyear;
document.getElementById("reportFrame").src = cmd;
}
else if(g_orglevel == 3){

// Defaulting the dropdown values to the parameter g_orgnumber
for(var i = 0; i < document.getElementById["cboDistrict").length; i++){

if(document.getElementById("cboDistrict").options[i].value == g_orgnumber){
document.getElementById("cboDistrict").options[i].selected=true;
break;
}
}
g_dropdnvalue = g_orgnumber;
g_dropdnname = 'D';
var cmd = "WFServlet?IBIF_ex=sccr_landingpage_rpt&P_DEPT_ID="+g_orgnumber+"&P_DEPTNAME="+g_dropdnname+"&P_EXPCTR="+g_expctrid+"&P_EXPCTR_NAME="+g_expctrgrp+"&P_ORGLEVEL="+g_orglevel+"&P_MONTH="+g_period+"&P_YEAR="+g_fiscalyear;
document.getElementById("reportFrame").src = cmd;
}
else if(g_orglevel == 4){

//If it is from store level we have to disable the other dropdowns except the District one
document.getElementById("cmdCompany").disabled = true;
document.getElementById("cboRegion").disabled = true;
document.getElementById("cboSpoke").disabled = true;


//* Defaulting the dropdown values to the parameter g_orgnumber
for(var i = 0; i < document.getElementById["cboStore").length; i++){

if(document.getElementById("cboStore").options[i].value == g_orgnumber){

document.getElementById("cboStore").options[i].selected = true;
break;
}
}
g_dropdnvalue = g_orgnumber;
g_dropdnname = 'S';
var cmd = "WFServlet?IBIF_ex=sccr_landingpage_rpt&P_DEPT_ID="+g_orgnumber+"&P_DEPTNAME="+g_dropdnname+"&P_EXPCTR="+g_expctrid+"&P_EXPCTR_NAME="+g_expctrgrp+"&P_ORGLEVEL="+g_orglevel+"&P_MONTH="+g_period+"&P_YEAR="+g_fiscalyear;
document.getElementById("reportFrame").src = cmd;
}

}
October 27, 2006, 09:51 AM
Bernie Ott
If I understand your problem correctly, your windowOnload() function is being called too quickly after the UpdateData() function is called.

Is that correct?

If so, the issue is that the UpdateData() function is simply setting up multiple AJAX connections to simultaneously populate listboxes, frames, etc.

Add the following code to your HTML page:
  
function WORKER(PARM1,PARM2) {
// whatever logic you need.
}
function OnLoad_Custom(frame,count,limit,milliseconds,command) {
   count++;
   if (frames[frame].document.readyState != "complete") {
       if (count < limit) { 
          setTimeout("OnLoad_Custom('"+frame+"',"+count+","+limit+","+milliseconds+",'"+command+"')",milliseconds);
       }
   } else { eval(unescape(command)); }
}


And then add the following after the UpdateData() function:

  
OnLoad_Custom('FRAMENAME',0,100,200,'WORKER("PARM1VALUE","PARM2VALUE");');


For the OnLoad_Custom function,
FRAMENAME = the frame you want to wait for it to be completely loaded
0 = always keep this 0
100 = # of times to loop waiting for FRAMENAME to completely load
200 = # of milliseconds to wait before checking for FRAMENAME to be completely loaded.

the final parameter is the actual function to call when FRAMENAME is fully loaded.
October 27, 2006, 09:53 AM
Bernie Ott
oh... I forgot to mention that FRAMENAME should be the value of the UNIQUE IDENTIFIER property for the frame.