Focal Point
[SHARING] Those who interested in AJAX and WebFOCUS

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

November 23, 2014, 01:33 PM
Rifaz
[SHARING] Those who interested in AJAX and WebFOCUS
AJAX mainly used for updating particular DOM without reloading the page.

I've 2 combobox and 2 text boxes in HTML, would like to update text boxes & combobox2 if combobox1 selection changes from ALL.

Associate ACombo1.fex to combo1 with ALL option

-* File ACombo1.fex
-DEFAULT &CNT='_FOC_NULL';
TABLE FILE CAR
PRINT COUNTRY
WHERE COUNTRY EQ '&CNT'
ON TABLE PCHOLD FORMAT XML
END  


On combo2, have static COUNTRY values.

In your HTML,
//Begin function combobox1_onchange
function combobox1_onchange(ctrl) {
	 document.getElementById("combobox2").value = "0";
    document.getElementById("edit1").value = "";
    document.getElementById("edit2").value = "";
if (document.getElementById("combobox1").value != "_FOC_NULL") {
	 alert("Values changed");
  callServer();
}
}
//End function combobox1_onchange

var xmlHttp = false;


if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

function callServer() {
 var val = document.getElementById("combobox1").value;
 var url = "/ibi_apps/WFServlet" + "?" + "IBIF_ex=rifaz/ACombo1.fex" + "&" + "CNT=" + val;
 xmlHttp.open("GET", url, true);
 xmlHttp.onreadystatechange = domupdate;
 xmlHttp.send(null);
}

function domupdate() {
 if (xmlHttp.readyState == 4) {
     if (xmlHttp.status == 200 ) {
    var responseXML = xmlHttp.responseXML;
alert("response OK");
         var trs = responseXML.getElementsByTagName("tr");
         var tds = trs[0].getElementsByTagName("td");
         var cb1 = tds[0].firstChild.nodeValue;
          if (cb1 == 0){
             document.getElementById("combobox2").options[0].selected = true;
             }
          else {
          document.getElementById("combobox2").value = tds[0].firstChild.nodeValue;
             }
    document.getElementById("edit1").value = tds[0].firstChild.nodeValue.trim();
    document.getElementById("edit2").value = tds[0].firstChild.nodeValue.trim();

}
}
}  

This message has been edited. Last edited by: Rifaz,


-Rifaz

WebFOCUS 7.7.x and 8.x
November 24, 2014, 08:56 AM
njsden
Thanks for sharing Rifaz.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
November 25, 2014, 04:34 PM
Waz
I have to admit that I am not impressed with IBI's implementation of FORMAT XML, as its HTML in an XML wrapper.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

November 26, 2014, 08:46 AM
stur0063
In the end - it's still just "parsing". But - I must admit - it took a bit more time to figure out what they were doing and parse it out because it's not exactly what I was expecting. So much for XPATHs :-)


webFOCUS 8207.15
WindowsServer 2019
April 17, 2015, 10:18 AM
WFDevConsultant
It might be a dumb or valid question.

Can this program will work on MRE? I have my HTML in MRE and the fex in server but it is not working. When I run the fex directly in the browser, it works.

By the way, I am running the HTML in developer studio, is that be a issue?


8.2.06
Windows, All Formats
April 17, 2015, 04:26 PM
GavinL
I happen to do a lot outside of WebFOCUS with WebFOCUS wrapped around it. I just find it easier. I'm currently doing Google Maps API, even though it can be done in WebFOCUS there are limits, but if I do it within HTML (fex), then I have only Google API limits and I can still use my data being called through WebFOCUS to drive the map.

So basically, because of customer requirements that expand way outside of WebFOCUS, but they still require the use of WebFOCUS, I wrap it in HTML like his example above.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
April 19, 2015, 09:32 PM
Rifaz
WFDevConsultant,

are you getting the "response OK" alert for responseXML variable?


-Rifaz

WebFOCUS 7.7.x and 8.x
April 19, 2015, 09:54 PM
WFDevConsultant
I am getting error when try to display the responseXML.


8.2.06
Windows, All Formats
April 20, 2015, 11:38 PM
Rifaz
I sent a private message to you.
April 21, 2015, 01:05 PM
eric.woerle
Not to long ago I was using readyState and found out that IE/FireFox/Chrome tend to use it differently. If your project needs to be cross browser compliant, I would suggest checking the big 3 to make sure that you get the results that your expecting.


Eric Woerle
8.1.05M Gen 913- Reporting Server Unix
8.1.05 Client Unix
Oracle 11.2.0.2
December 14, 2016, 10:24 AM
zcbillions
Hi Rifaz,

I'm trying to use your AJAX to refresh some parameters/filters in a HTML Page. I have 9 basic bar charts and 9 different parameters tied to those bar charts. I have some chaining going on with the parameters, but I want to tie all the parameters together (they are all in one hold file) and have them updated. For example) I have region, country, business unit, and sales rep all chained together, but if the user selects the lowest level, sales rep, I want the business unit, country, and region updated. That's just one process flow. Like I mentioned before I need all the parameters updated once the user selects one parameter. Can you help me out with this?

Thank you


WebFOCUS 8
Windows, All Outputs
January 03, 2017, 01:12 AM
Rifaz
Apologies for being too late to reply. I don't get a time to visit focal point now a days as I'm into infrastructure admin.
Have you looked into "Magically filter Reports in BI Portal" doc? I think that may solve your problem.


-Rifaz

WebFOCUS 7.7.x and 8.x