Embedding a Reusable Part in a 3rd Party Web Page

This forum allows developers to post programming tips and coding techniques that may be useful to other Visual LANSA developers. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Dom
Posts: 1
Joined: Wed Feb 03, 2016 5:34 pm

Embedding a Reusable Part in a 3rd Party Web Page

Post by Dom » Wed Feb 03, 2016 6:28 pm

This is covered in the documentation, but the sample code supplied will not work in the V14GA release of LANSA. The difference is in the code to initialize the LANSA runtime:

Code: Select all

// Initialize the LANSA runtime
LANSA.init({sys:"%{lansa_webalias}%",part:"%{lansa_partition}%",lang:{ def:"ENG",code: { "ENG":"en-US", "FRA":"fr-FR", "JPN":"ja-JP" } },splash:{ limg:"spin",txt:"Loading..." } } );
The correct code should be

Code: Select all

// Initialize the LANSA runtime
LANSA.init({System:"[web alias]",Library:"lansa_14_0_0_1",Partition:"[partition]",lang:{ def:"ENG",code: { "ENG":"en-US", "FRA":"fr-FR", "JPN":"ja-JP" } },splash:{ limg:"spin",txt:"Loading..." } } );
Where [Web Alias] is the name used in your URL when you execute a VL Web Page; i.e. if the URL http://localhost/l4w-tip/wex/testvlweb.html?lang=eng then the Web alias is l4w-tip. Note this is the same value that should go into the [path] section of the script line described earlier. [Partition] is the execution partition, in lower case.

The code in the documentation is for the upcoming EPC, which simplifies the process, however the existing method (with System, Library and Partition) will still be supported. Note also the use of %{lansa_webalias}% type environment variables is only supported when the webpage displaying the reusable part is actually hosted in the partition/web/vl directory.


Lastly, it is only possible to include reusable parts in web pages like this if LANSA for the web is installed onto the same webserver. Displaying RPs on your existing non-LANSA website, that are 'served' from an external (i.e. IBM i based) LANSA webserver is not possible with this method, however it is possible to use this technique to create a static webpage on the LANSA webserver, which can then be included on other webpages using the HTML Object tag:

Code: Select all

<object type="text/html" data="http://<mylansawebserver>/ShowLANSA.html" width="850px" height="850px" style="overflow:auto;border:5px ridge blue">
</object>
Please be aware that some browsers/security settings may block or restrict content on pages coming from external sources.

The full (simple) HTML code for ShowLANSA.html looks like this:

Code: Select all

<HTML>
  <HEAD>
    <TITLE>Embedding a Reusable Part into HTML</TITLE>
  </HEAD>
<BODY>
  <div id="LANSAFrame" style="top:0px;left:10%;width:80%;height:800px;position:absolute"></div>
  <script src="/l4w-tip/lansa_14_0_0_1/lansa.js">
  </script>
  <script>
    // Initialize the LANSA runtime
    LANSA.init({System:"l4w-tip",Library:"lansa_14_0_0_1",Partition:"wex",lang:{ def:"ENG",code: { "ENG":"en-US", "FRA":"fr-FR", "JPN":"ja-JP" } },splash:{ limg:"spin",txt:"Loading..." } } );

    // Create the reusable part (myPart), it will fill up the nominated DIV
    var myPart = LANSA.showPart( "DomTest", "LANSAFrame" );
  </script>
</BODY>
</HTML>

Post Reply