A WAM is a component that supports the web paradigm. A WAM outputs XML containing the fields and lists that are to be passed into its output web page. This web page is created via an XSLT transformation. The XSL reads the output XML and generates the XHTML. A web server associated with your web application then forwards this XHTML to the user's browser.
The XSLT transformation uses other LANSA XSL components, known as weblets. These weblets provide web components that can be added into a page and configured. They have properties which can be set both at design time and run time as required. Weblets include relatively simple components such as a push button or clickable image as well as much more complex components such as a grid, or tree view.
The web page layout is controlled by a layout weblet. A layout weblet is assigned when the WAM is compiled and may be modified both at design time and run time.
The WAM Design view provides a graphical editor that enables the developer to define the appearance and behavior of the web page that is output for a web routine. A weblet such as a push button can be dropped onto the page and then set up via its properties using the Details tab.
A WAM usually contains a number of web routines. Each web routine is a program entry point – it can be invoked via link on a web page for example. When a web routine ends, it outputs its fields and lists as an XML document.
Mapping of data into and out of a web routine is controlled by WEB_MAP statements. A WEB_MAP defines whether fields are mapped into or out of the web routine, or in both directions, via a FOR() parameter. Fields and lists are mapped via the WEB_MAP FIELDS() parameter. Fields and lists may have display attributes that control whether the field is input capable (the default) or output only. Other field attributes such as *private and *hidden, may be used.
Some Example WEB_MAP StatementsWEB_MAP FOR(*OUTPUT) FIELDS(#EMPNO)
Field EMPNO is mapped out of this Web Routine. EMPNO is input capable on the page.WEB_MAP FOR(*INPUT) FIELDS(#EMPNO)
Field EMPNO is mapped into this Web Routine. EMPNO is not mapped out of this Web Routine to the page.WEB_MAP FOR(*BOTH) FIELDS((#EMPNO *OUTPUT) #SURNAME #GIVENAME)
Fields are mapped into and out of this Web Routine. Field EMPNO is output on the page and therefore cannot be mapped into the next Web Routine.WEB_MAP FOR(*BOTH) FIELDS((#STDRENTRY *HIDDEN))
Field STDRENTRY is mapped into and out of this Web Routine. STDRENTRY is a hidden field defined in the XHTML but not shown on the web page.
A WAM application should be considered as having two layers:
One of the key points to understand about WAMs is that they are stateless. In fact, any internet-based application is stateless. What this means is that when a WAM is executed from the Presentation Layer, it runs (a job is initiated on the server), produces some output (a web page), and then ends (the job on the server ends and control is transferred back to the browser).
The job starting and ending, to all intents and purposes, is a "transaction". Any data that needs to be maintained for the user's web "session", i.e. span multiple transactions, must be kept somewhere. As you complete the following simple example WAM, you will begin to see how a web application needs to be designed to handle this "stateless" model.
Using Long Names
Components can be defined using Long Names. This is an optional setting at Partition level. When you create a WAM, form or a reusable part using a Long Name, Visual LANSA will assign a unique Identifier (this is up to 10 characters in length). As you are creating a new component, you may choose to assign your own Identifier, which provides complete control to a team of developers, of both Long Names and Identifiers.
See the topic LANSA Object Names in the Technical Reference guide for further information.
This workshop assumes that Long Names are enabled.