Focal Point
[RESOLVED] Accessing Individual Values in !IBI.FIL

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

January 05, 2016, 06:01 PM
TheRabbit
[RESOLVED] Accessing Individual Values in !IBI.FIL
I am an absolute newbie to WebFocus. I have seen the product for over a decade now but have never had to actually produce anything for a client until now. The client has essentially asked me to create a free form report in html. I have been searching for days on the best direction to take. I have already built a POC for them in html that mimicked the design from their creative department. What I am trying to do now is somehow populate the html with results from a fex. As a test, I created a fex that will create a HOLD table. What I want to do now is access each individual value of the HOLD table so that I can put it were it belongs on the html form.

I suppose my first question would be whether what I want to do is even possible. Can I access each value of the HOLD table so that I can format it and place it where I want it in the html?

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


Release 8.007
Windows, HTML
January 06, 2016, 01:51 AM
Dave
hi, welcome to WF.

You really need some basic training.
This is not something you want to achieve with !IBI.AMP stuff.

Use either the WF-solution ( i.e. make the HTML in WF GUI an let it populate the form ) or use scripting. ( HTTPRequest object, JQuery, whatever ).

...do training.


_____________________
WF: 8.0.0.9 > going 8.2.0.5
January 06, 2016, 04:34 PM
TheRabbit
Thanks for your insight, Dave. Unfortunately there is no time for training. I did do some basic training a few months back and found that stuff to be very easy to accomplish, but what I need to do now is much more complicated. It is essentially a free-form report in html. I investigated and did some POC work to see if it was a viable solution but I don't think it will be because I cannot control the height of the rows and, as I understand it, cannot do drill downs.

My problem with using the WF GUI to do the HTML is that it already has an expectation on the formatting of the results so I guess I am really going to have to step outside the box and use scripting as you suggested.

Again, thanks for just telling me like it is...

DJ


Release 8.007
Windows, HTML
January 06, 2016, 04:45 PM
Squatch
I just posted a possible solution for someone who wanted to dynamically retrieve data into a double listbox:

On click of a button it has to load the data in double list control dynamically

You should be able to use that same technique to insert data anywhere into your HTML document. It uses plain old JavaScript but JQuery would be easier.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
January 06, 2016, 04:54 PM
TheRabbit
Looking at it now, Squatch. Hopefully it will save me a lot of trouble. I will keep you posted!


Release 8.007
Windows, HTML
January 06, 2016, 05:04 PM
Squatch
And using JavaScript or JQuery, you should be able to dynamically create or remove elements depending on how much data you pull in.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
January 08, 2016, 01:09 AM
TheRabbit
Squatch, I have been working through your code and cannot seem to get the XMLHttpRequest to operate properly. Ultimately the status never gets set to 200. I did some alert messaging and the first time through, once the readyState gets to 4, I receive an error. I assume it is because the status is null. Once I do get a value for the status, it is set to 404. Any idea as to what might be causing this?


Release 8.007
Windows, HTML
January 08, 2016, 01:16 PM
Squatch
A 404 would indicate that there is something wrong with your URL. If you haven't done so already, test your URL in a browser to make sure something is being returned.

Or, you can put in an alert that displays your URL so you can be sure it is correct.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
January 08, 2016, 04:45 PM
TheRabbit
Success!

To accomplish what I needed to do, I did a mix javascript and jQuery to populate a span with a specific id. I will try to reproduce this using some sample data and present it here for posterity and the good of the community!


Release 8.007
Windows, HTML
January 08, 2016, 07:02 PM
Squatch
Excellent!


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
January 08, 2016, 10:38 PM
TheRabbit
Here is some trimmed down version of my solution. I am using both javascript and jQuery to show two fields on the page that are placed where ever I want them to go.

The data comes from a fex and stored as XML. For this example, I only need the first record.

-* Focexec: car.fex
TABLE FILE car
PRINT CAR
      MODEL
WHERE RECORDLIMIT EQ 1
ON TABLE PCHOLD FORMAT XML
END
-RUN


<html>
<head>
<title>Free Form Reporting Example</title>
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
 </script>
 <script>
  $(document).ready(function(){
 
// Prepare for Ajax calls
var xmlHttp = false;
 
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
 xmlHttp = new XMLHttpRequest();
}
 
// Set the FEX procedure to call, then call it
// The FEX is stored in the crm folder
var url = "/ibi_apps/WFServlet" + "?" + "IBIF_ex=crm/car.fex";
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = domupdate;
xmlHttp.send(null);
 
// Update the spans with the new information
function domupdate() {
 if (xmlHttp.readyState == 4) {
  if (xmlHttp.status == 200) {
   var responseXML = xmlHttp.responseXML;
   var i;
   var j;
 
   var trs = responseXML.getElementsByTagName("tr");
   var indv = [];
   for (i = 0; i < trs.length; i++) {
    var tds = trs[i].getElementsByTagName("td");
    for (j = 0; j < tds.length; j++) {
     indv.push(tds[j].firstChild.nodeValue);
    }
   }
   $("#car").text(indv[0]);   // the values were stored in an array
   $("#model").text(indv[1]); // in the order they were delivered in the fex
  }
 }
}
 
  });
 </script>
</head>
<body bgColor=#ffffff>
<h1>Free Form HTML Example</h1>
<p>This example will automatically populate the two fields below called Car and Model when the page loads.</p> 
<SPAN style="Z-INDEX: 42; BORDER-BOTTOM: black thin solid; POSITION: absolute; LINE-HEIGHT: 10pt; BACKGROUND-COLOR: silver; PADDING-LEFT: 10px; WIDTH: 99px;
 FONT-FAMILY: Arial; HEIGHT: 21px; FONT-SIZE: 8pt; BORDER-RIGHT: black thin solid; PADDING-TOP: 5px; TOP: 160px; LEFT: 30px" id=Text1>Car</SPAN>
<SPAN style="Z-INDEX: 43; BORDER-BOTTOM: black thin solid; POSITION: absolute; BACKGROUND-COLOR: white; PADDING-LEFT: 5px; WIDTH: 163px; FONT-FAMILY: Arial;
 HEIGHT: 21px; FONT-SIZE: 8pt; PADDING-TOP: 5px; TOP: 160px; LEFT: 140px" id=car></SPAN>
<SPAN style="Z-INDEX: 42; BORDER-BOTTOM: black thin solid; POSITION: absolute; LINE-HEIGHT: 10pt; BACKGROUND-COLOR: silver; PADDING-LEFT: 10px; WIDTH: 99px;
 FONT-FAMILY: Arial; HEIGHT: 21px; FONT-SIZE: 8pt; BORDER-RIGHT: black thin solid; PADDING-TOP: 5px; TOP: 187px; LEFT: 30px" id=Text2>Model</SPAN>
<SPAN style="Z-INDEX: 43; BORDER-BOTTOM: black thin solid; POSITION: absolute; BACKGROUND-COLOR: white; PADDING-LEFT: 5px; WIDTH: 163px; FONT-FAMILY: Arial;
 HEIGHT: 21px; FONT-SIZE: 8pt; PADDING-TOP: 5px; TOP: 187px; LEFT: 140px" id=model></SPAN>
</body>
</html>


I hope you find this helpful for future projects. Good luck!

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


Release 8.007
Windows, HTML