ASNA
MobileRPG® Reference Manual |
Warning – This feature is deprecated as of version 8.0.18.0. When new
websites are generated the App_Data/AlternatePages.Config
file is no longer created, nor is the code to process such files included
in Global.asax.
When a 5250 Terminal (Emulation) page is displayed, and the device running the
browser (or AsnaGo) is a Tablet (identified by the window.navigator.userAgent
DOM property having a value that contains the words "iPad", "iPhone", "iPod", "Android" or "Touch"),
the page will be replaced with a version in the "Tablet" folder of the same name. This remains the
default behavior of the "Alternate Pages" feature, concerning the 5250 Terminal Emulation.
If the developer must refine the logic that determines when will the Tablet version of the 5250 Terminal Emulation should be used, it is now necessary to change the following global JavaScript function:
File | ..\Themes\Current\Asna5250Terminal.aspx |
Function | checkTabletRedirect() |
Parameters | none |
Return Value | (Boolean) true if the current page should be replaced with the Tablet version, false if the page should not be replaced. |
Developers often have no control over the devices their web pages will be viewed on, and with the ascension of smart phones and tablets, it can be extremely difficult to design a page that looks and functions ideally on all likely form factors. To help handle this issue, the Monarch Framework includes a system that allows developers to create distinct (although usually very similar) pages for various devices.
Instead of trying to design pages that will look good in all devices, the Mobile application developer may want to provide "Alternative" "Pages" pages for some devices. For example, if the device can be identified as a Phone, then the alternative page may hide some (non-essential) information and use a different layout.
The way in which Mobile RPG (via the Monarch Framework) allows different Web Pages to be loaded, given the same name of the Web Page (since the display file the application is requesting remains the same), is through the use of folders. These folders all share the same root (the Website "Views"). The syntax of the configuration table refers to them as "subfolders".
The ReadAlternatePagesConfig() method in Global.asax loads into memory a "folder-lookup table" keyed by an expression based on the "UserAgent" (which is the way a browser identifies itself) – see http://en.wikipedia.org/wiki/User_agent.
The "folder-lookup table" is an xml file stored in
..\App_Data\AlternatePages.config
An AlternatePages.config file might look like the following:
Each "Redirect rule" above uses the Browser User-Agent (http://en.wikipedia.org/wiki/User_agent) with the string expression "contains", such that if the result is true, Mobile RPG will attempt to find the page in the subfolder indicated. If an aspx file is found in the subfolder, that page will be used. If no such file is found, then the page in the root (~/Views) will be used instead.
The User-Agent string is rather long and cryptic. It is intended to be unique, but normally just a few pieces are necessary to identify the device in question. The file above shows typical values of the User-Agent string for different devices as comments. (Comments are ignored by XML )
Example
The first rule (<agentcontains="iPad" . . . )
will be true if the
User-Agent string contains the word "iPad". If the
browser requesting the page is a Windows PC running
Mozilla Firefox, the
value may be "Mozilla/5.0
(compatible; MSIE 10.0; Windows NT 6.1;
Trident/6.0)"
and the
expression
contains="iPad"
evaluates
to false, therefore the subfolder "Tablet" will not
be used while searching for the requested Page.
In
contrast, if the device requesting the page is an
Apple iPad, then the value of the User-Agent will
likely be "Apple
iPad: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS
X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko)
Version/4.0.4 Mobile/7B334b Safari/531.21.10"
and
the expression
contains="iPad"
evaluates to true, therefore the subfolder "Tablet" will be used (i.e.
Wings will look in ~/Views/Tablet" first for the
requested page.
Note: The
..\App_Data\AlternatePages.config
should be adjusted
to the Application needs. The implementation of
ReadAlternatePagesConfig()
should
not be changed.
Configuring
In order to make use of this system, a developer need only create (or more likely copy, then modify) a version of their web page within each of the desired subfolders.
Adapting a site to best serve mobile users is beyond the scope of this guide, but helpful resources can be found here: http://designm.ag/tutorials/21-best-websites-for-teaching-yourself-web-development/