3.1 My First Web Page


This is a really simple example of a Web Page to illustrate how it all hangs together.

To create a "Hello world" web application, you could drag and drop a push button onto a Web Page and then add code for the button click event to show an alert. The resulting code might look like the following:

Begin_Com Role(*EXTENDS #PRIM_WEB)
Define_Com Class(#PRIM_PHBN) Name(#Button) Displayposition(1) Left(63) Parent(#COM_OWNER) Tabposition(1) Top(27) Caption('Click Here') Height(50) Width(150)
Evtroutine Handling(#Button.Click)
  #sys_web.alert( "Hello World" )

If you like, cut and paste this code and create your own Web Page, then from the Home ribbon, save and compile the Web Page.

Executing the Web Page, again from the Home ribbon, will launch your default browser and run your "Hello World" application based on you default web server, which hopefully will look something like this. Be sure to click the button to activate the alert.

That's it, you have just created and executed your first web page using Visual LANSA.

On last thing before we move on. Going back to the Home ribbon, if you want to nominate a different target browser and/or base URL to be used when executing the web page, use the dropdown on the execute to select the appropriate options.

Note - The Base URL options can be set in the LANSA Settings. Refer to 2. Web Server Up and Running for more information.