I'm trying to create a link for APM in VL-Web application. There are two items that I'm failing to get working
The base item is supposed to go into the web page header. I seem to be able to create a new base JS item using Integration but it doesn't go into the header. I therefore have "hacked" the produced .html file to put this in. Not ideal. Is there any way to put it into the header?
The second part is probably my lack of JS knowledge. The JS put into the header creates a reference like this
<script>
var appAPM = window.appAPM || function (cfg)
{
:
: initialisation stuff
:
}
window.appAPM = appAPM;
app.callfunction();
</script>
That bit works fine. The cloud based APM sees the WebPage being started. I then have created a widget for more detailed APM items.
PROTOTYPE.uEvent = function( strEventName )
{
var appAPM = window.appAPM;
appAPM.appEvent(strEventName );
}
However, I get an error:
Uncaught TypeError: Cannot read property 'appEvent' of undefined
I am presuming from the error that appAPM isn't being correctly repointed to the window.appAPM. Is this the correct way to do the widget?
Widget calling external window ref
-
dannyoorburg
- Posts: 177
- Joined: Mon Jan 04, 2016 9:50 am
- Location: Australia
Re: Widget calling external window ref
Hi,
hope you've figured it out by now
If not, even though it's hard for me to tell you exactly what's wrong without more info, I just thought I'll give you some tips.
I don't think there's any need to 'hack' the header. It just looks like some code that needs to run BEFORE any code using it will ever run. If you look at the xGoogleMaps widget for instance, you'll see it has the following url
https://www.google.com/jsapi
on its Resource tab, plus in the defining function you'll see;
Basically, before the first widget INSTANCE is created, LANSA will first
1. Download all resources
2. Execute the Widget Definition function (only then and never again)
THEN and only then can it use the PROTOTYPE to create the instance.
So in general there's no need to run code in the HTML, or to add script tags to the HTML. Add the scripts to the resources, and run the code at the start of the Widget Definition function.
Regards,
Danny
hope you've figured it out by now
If not, even though it's hard for me to tell you exactly what's wrong without more info, I just thought I'll give you some tips.
I don't think there's any need to 'hack' the header. It just looks like some code that needs to run BEFORE any code using it will ever run. If you look at the xGoogleMaps widget for instance, you'll see it has the following url
https://www.google.com/jsapi
on its Resource tab, plus in the defining function you'll see;
Code: Select all
//------------------------------------------------------------------------
// LOAD GOOGLE MAPS, ONLY WHEN THAT IS COMPLETED IS THE WIDGET READY TO GO
//------------------------------------------------------------------------
google.load( 'maps', '3', { other_params: 'key=' + apiKey + '&sensor=false', callback: WIDGET.Finalize } );
Basically, before the first widget INSTANCE is created, LANSA will first
1. Download all resources
2. Execute the Widget Definition function (only then and never again)
THEN and only then can it use the PROTOTYPE to create the instance.
So in general there's no need to run code in the HTML, or to add script tags to the HTML. Add the scripts to the resources, and run the code at the start of the Widget Definition function.
Regards,
Danny
Re: Widget calling external window ref
Danny,
That tip was perfect. It made the whole integration bit a lot easier
Thank you
Paige
That tip was perfect. It made the whole integration bit a lot easier
Thank you
Paige