Focal Point
[CLOSED] Performance problems using ajax

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

April 09, 2009, 09:39 AM
Håkan
[CLOSED] Performance problems using ajax
We're initially loading 14 listboxes when we open an app. It works fine, except that it takes forever. It feels like all the 14 xmlHttp requests slows it down. Is it possible to run just one request and let WF take care of different entry points in the fex etc.?

Tia
Håkan

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


WebFOCUS DS 8.0.06/08 DS/AS
WebFOCUS RS 8.0.08 (Linux/IBM i)
WebFOCUS Client 8.0.06 (Linux)
April 09, 2009, 09:56 AM
dhagen
I don't know where the doc is for this, but you can create a fex that contains the output for all of the drop/list boxes. I've only ever done this for chained values, but it reduced the time to load significantly.

If someone else here cannot provide a doc link, then call CSS in NY.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
April 09, 2009, 10:13 AM
bug
Try using insynchronized ajax call instead of synchronized. In that way the server can process multiple ajax calls in the same time.


7.66 and 7.704
System: Windows / AIX / Linux
Output: Mostly HTML, with some PDF, Excel and Lotus(!)
April 09, 2009, 05:33 PM
susannah
Stockholm,
yes you can produce one big array with all of your dropdowns, but its big, and loads all into the users browser.
TonyA and I were going to do a prez at Summit about this...but the powers that be nixed us !
Here's an example; you can try it.
you write 1 fex, and use the same fex for each of your dropdowns,
TABLE FILE MYDIMENSIONS
SUM       BUSINESS
          CORPORATION
	 DIVISION
	 DEPARTMENT
	 PROGRAM
BY BU_ID
BY CORP_ID
BY DIV_ID
BY DEPT_ID
BY PROG_ID
ON TABLE PCHOLD FORMAT XML
END

where the BY Fields are the parameter values and the Display fields are the pretty names.
Imagine a giant Javascript array.
Let us know how you make out.
-Happy Holiday
-s

ps: leave cacheruntimedata=1 for all the parms in your launch page.

pps: the benefit of this big array is that its omni-directional.

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




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
April 10, 2009, 08:50 AM
gregv
susannah,
I like your solution.

Tia,

Here is another option:

Are you doing the AJAX calls yourself? Are you chaining the dropdowns? Do you use 'ALL' as one of the select items?

You can do the AJAX calls yourself and it's MUCH faster. If you chain the lists then you have to do the chaining yourself which is a challenge.

You can mix different ways to retreive the data using WF for the smaller lists with or without chaining and direct AJAX for the larger lists.

If you use 'ALL' and the lists are chained then you can show the 'ALL' option when the page first displays without populating the list and then retreive each individual list if/when the user clicks on it's dropdown arrow.

Search in this forum for AJAX. There are a lot of good examples.

Good luck.



Greg



current client: WF 8.1.05 & 8.2 - Windows 7 64bit - Tomcat 7 - MRE / BID - IE11

local: WF 8.2 - Windows 7 64bit - Tomcat 6 - MRE / BID - FOCUS - IE11

PMF 8
April 13, 2009, 04:30 PM
Waz
If you are writing your own, you can extract multiple lists in one call and return them, then let the js pull out each list from the XML.

The secret is to create an XML document that has multiple parts.

All I did for prep is to append all XML documents, remove the xml wrappers and fxf tags, change the target property (for ident purposes), and add a new xml wrapper and FXF tag.

The script then reads the document, checks the target, which corresponds to the control, and loads the info.


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!

April 14, 2009, 12:17 AM
Håkan
Yes, I'm doing the AJAX calls myself, since it's much faster, but not fast enough.

Waz, are you willing to share the code for that?

Tia
Håkan


WebFOCUS DS 8.0.06/08 DS/AS
WebFOCUS RS 8.0.08 (Linux/IBM i)
WebFOCUS Client 8.0.06 (Linux)
April 14, 2009, 01:08 AM
Waz
Håkan

Here is the simplified extract portion of the code.

FILEDEF COUNTRY DISK _p_list.xml (APPEND

-RUN

TABLE FILE CAR
PRINT COUNTRY     AS 'CODE'
      COUNTRY     AS 'DESC'
ON TABLE HOLD AS COUNTRY FORMAT XML
END

-RUN

FILEDEF COUNTRY CLEAR
FILEDEF CAR DISK _p_list.xml (APPEND

-RUN

TABLE FILE CAR
PRINT CAR         AS 'CODE'
      CAR         AS 'DESC'
ON TABLE HOLD AS CAR FORMAT XML
END

-RUN

FILEDEF CAR CLEAR
FILEDEF MODEL DISK _p_list.xml (APPEND

-RUN

TABLE FILE CAR
PRINT MODEL       AS 'CODE'
      MODEL       AS 'DESC'
ON TABLE HOLD AS MODEL FORMAT XML
END

-RUN

FILEDEF MODEL CLEAR
FILEDEF _P_LIST DISK _p_list.xml

-RUN

-SET &Multi_Count = 3 ;
-SET &P_MULTI_NAME= 'COUNTRY|CAR|MODEL' ;

-* Write out a master to read the _P_LIST list
EX -LINES 4 EDAPUT MASTER,_P_LIST,CV,FILE
FILENAME=_P_LIST, SUFFIX=FIX,$
SEGNAME=_P_LIST, $
  FIELD=XMLLINE ,ALIAS=  ,A500 ,A500 ,$

-RUN

DEFINE  FILE _P_LIST
 LINE/I9    = LAST LINE + 1 ;
 XML_TAG/A1 = IF EDIT(XMLLINE,'99999') EQ '<?xml' THEN 'Y' ELSE 'N' ;
 FXF_TAG/A1 = IF EDIT(XMLLINE,'9999')  EQ '<fxf' OR EDIT(XMLLINE,'99999') EQ '</fxf' THEN 'Y' ELSE 'N' ;
 Filter/A4  = IF (XML_TAG EQ 'Y')
              OR (FXF_TAG EQ 'Y')
              THEN 'N'
              ELSE 'Y' ;
END

TABLE   FILE _P_LIST
 PRINT  
        XMLLINE

 WHERE  TOTAL Filter EQ 'Y'

 ON     TABLE SAVE AS _P_XML
 ON     TABLE SET HOLDLIST PRINTONLY

END

-RUN

SET HTMLFORMTYPE = XML

-HTMLFORM BEGIN
<?xml  version="1.0" encoding="ISO-8859-1"?>
<fxf  version="1.0" data="hold">
!IBI.FIL._P_XML;
</fxf>
-HTMLFORM BEGIN


The js code will take a little time to sanitise.


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!

April 16, 2009, 06:27 PM
Waz
The js call uses ibi's xmlhttp js library.

	var ibihttp = new ibihttpxml(_Action,null);
	var leftHtml = null;
	ibihttp.openFromForm(document.forms.Get_List);
	var selctDocs = ibihttp.selectNodes("//fxf/report");
	if (selctDocs.length>0) {
		for (var _c1=0;_c1<selctDocs.length;_c1++) {
			var _targt = ibihttp.selectNodesFromNode(selctDocs[_c1],'target') ;
			if (_targt.length>0) {
				var _SelList = document.getElementById(_targt[0].getAttribute("destination")) ;
				var selctTable = ibihttp.selectNodesFromNode(selctDocs[_c1],'table') ;
				if (selctTable.length > 0) {
					var selctNodes = ibihttp.selectNodesFromNode(selctTable[0],'tr') ;
					if (selctNodes.length>0) {
						for (var _c2=0;_c2<selctNodes.length;_c2++) {
							var _Kids = selctNodes[_c2].childNodes ;
							var _Opt = document.createElement("OPTION") ;
							_SelList.add(_Opt) ;
							_Opt.innerText = _Kids[1].nodeTypedValue ;
							_Opt.value     = _Kids[0].nodeTypedValue ;
						}
					}
					_SelList.disabled = false ;
					_SelList.selectedIndex = 0 ;
				}
			}
		}
	}


The _Action variable is the call to WF, the target relates to the select object, and the select object has been preprocessed to clear out what is there.


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!

April 17, 2009, 02:26 AM
Håkan
Thanks Waz, I'll give it a try.

Håkan


WebFOCUS DS 8.0.06/08 DS/AS
WebFOCUS RS 8.0.08 (Linux/IBM i)
WebFOCUS Client 8.0.06 (Linux)