About URLs and the generated HTML

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
dannyoorburg
Posts: 176
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

About URLs and the generated HTML

Post by dannyoorburg » Wed Apr 06, 2016 12:25 pm

If you run a web-page from the IDE you will notice a URL like:

http:// localhost/ lansa14 / dem / xedmain.html ? lang=eng & developer=yes

What does this mean?

In bold, from left to right, we’ve got:

- system id
- partition id
- webpage id
- language parameter
- development parameter

How is this information used?

This URL is inspected by the LANSA Web Plugin, it uses the system/partition id to retrieve the generated HTML from the Application Server.

NOTE: The generated HTML is really a template, it has some substitution markers, which are used by the Web Plugin to substitute the system and partition id into its response HTML. The HTML needs it so that additional resources, like the JavaScript that is required to make it run, can be requested through similarly formatted URLs.

It will eventually return something like this:

Code: Select all

<!DOCTYPE html>
<html lang="en" style="height:100%">
   <head>
      <meta charset="utf-8" />
      <meta name="mobile-web-app-capable" content="yes">
      <meta name="apple-mobile-web-app-capable" content="yes">
      <meta name="apple-touch-fullscreen" content="yes">
      <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
   </head>
   <body style="height:100%; margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom:0px">
      <script src="/lansa14/lansa_14_0_1_0/lansa.js"></script>
      <script>
         (function(LANSA){
            if(!LANSA){document.write("Failed to load lansa.js");return}
            LANSA.init({part:"dem",sys:"lansa14",lang:{def:"ENG",code:{"FRA":"fr-FR","JPN":"ja-JP"}},splash:{limg:"spin",mtxt:{"ENG":"Loading...","FRA":"Loading...","JPN":"Loading...","LLL":"Loading..."}}});
            LANSA.showPage("XEDMAIN");
         }(window["LANSA"]))
      </script>
      <noscript>This page requires JavaScript.</noscript>
   </body>
</html>
You'll notice the lines:

<script src="/lansa14/lansa_14_0_1_0/lansa.js"></script>
...
LANSA.init({part:"dem",sys:"lansa14", ...

Where you see the system/partition id being made available inside the HTML.


So, to execute a Visual LANSA Web Application, it needs to start with HTML like this, which contains the system and partition id so it can request additional resources back of the application server.

Of course, this HTML doesn't necessarily have to be delivered through the process described above.

If your website goes into production, and you like to make it available through a classic http://www.mysite.com/index.html, you can do that. You can grab the HTML as provided by the Plugin, copy it into an index.html and put it on your Web Server. Now your web application is up and running with a simple URL (http://www.mysite.com), and you no longer rely on the URL to provide the application server details, instead it's hard-coded into the HTML.

What about the language parameter?

You’ll notice the HTML specifies which languages are supported, as well as which language to use if NO language parameter is present on the URL. So you generally don’t need it unless you've re-directed users to run your page in a non-default language.

What about the developer=yes parameter?

“developer=yes” is (of course) purely for development.

How the browser-caching behaves depends on whether or not your Web Page uses the Application Cache (see the Offline Support Tab).

WITH a cache manifest, the browser will ONLY refresh resources if the cache manifest file itself has changed, which you accomplish by re-compiling the Web Page.

WITHOUT a cache manifest, the browser will refresh resources based on all the standard rules to do with expiry headers etc..

“developer=yes” is a trick to bypass the browsers caching at development time, so you don't have to remember to re-compile the containing Web Page every time you make a change to a reusable part.

In production you DO want caching (specifically if you start making offline capable applications). Make sure re-deploy the cache manifest file, if you use one, even if you're just changing a reusable part.


I hope this is helpful, let me know if there are any questions. I'm very interested in any additional thoughts on deploying to a production system and configuring the URL's.

Danny

faridah.belandres
Posts: 6
Joined: Wed Jul 13, 2016 1:57 pm

Re: About URLs and the generated HTML

Post by faridah.belandres » Tue Aug 02, 2016 8:15 pm

Hi Danny,

Good day!

I would like to ask if it is possible to embed the script tags from your example in a certain div inside a WAM?
For example, in my WAM's XSL part, I added a div.
Inside that div, I tried to add similar script tags from your example.
However, when the web page loaded, it occupied the whole page and not just the portion of the div.

I hope I'm making sense.

Thank you in advance,
Faridah

dannyoorburg
Posts: 176
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: About URLs and the generated HTML

Post by dannyoorburg » Wed Aug 03, 2016 9:55 am

Hi Faridah,

if you want Visual LANSA to just fill a div on an HTML page, you'll need to use

LANSA.showPart

instead of

LANSA.showPage

and you nominate a Reusable Part to show and a div to show it in..

See http://docs.lansa.com/14/en/lansa017/in ... 1_0580.htm

Cheers,
Danny

faridah.belandres
Posts: 6
Joined: Wed Jul 13, 2016 1:57 pm

Re: About URLs and the generated HTML

Post by faridah.belandres » Fri Aug 05, 2016 11:30 am

Hi Danny,

Good day! Thank you again for your reply.

I tried the LANSA.showPart instead of LANSA.showPage.
The reusable part was successfully displayed in the specified div.
However, when I tried to replace (in the LANSA.showPart) the reusable part identifier with an identifier of a web page,
an error appeared:
Fatal Error: Cannot realize a child window with a null parent

Do you have an idea what the error means?

I also tried to use an iFrame instead of a div but got the same error.
I guess the LANSA.showPart only accepts reusable part identifier for the first parameter.

Thanks,
Faridah

dannyoorburg
Posts: 176
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: About URLs and the generated HTML

Post by dannyoorburg » Fri Aug 05, 2016 11:44 am

Hi Faridah,

Yes, the ShowPart method expects a Reusable Part.
A Web Page expects to be the whole page (or the whole frame if you show it in an iframe).

Maybe it would be easier to put an iframe on your page and point it to a web page url.

It all depends on what you're trying to achieve.

Danny

Post Reply