ASNA Mobile RPG® Reference Manual

Customizing the MobileRPGJob Class to Support Limited Capability Users

As discussed in greater detail in the Limited Cabability Users topic, IBM i user profiles with Limited Capability settings other than *NO have their options restricted by i5/OS, and one of these restrictions is the inability to specify the Current Library or initial Program to run while signing on to the system.

When Mobile RPG establishes a connection to the IBM i through DataGate, it normally requests that the DataGate server be available to receive and process commands sent from the web site. In order for the DataGate job to comply with this request, it must specify itself as the initial program for the starting job so that it can sit on a loop processing commands sent from the DataGate client; this is something that can't be done for limited users.

DataGate also has the ability to start in a restricted mode where it can support 5250 data streams through programs with the handler but is unable to provide any other services. This restricted mode is available to all user profiles: limited or not. The application will start according to the user profile's initial program settings.

By default, the MobileRPGJob class created as part of a Mobile RPG website assumes unlimited user profiles and provides a sign-on screen where the user can provide its credentials and (mimicking the i5/OS sign-on screen) a library, program and menu, as shown in the images below.

If the user provides any of these values, MobileRPGJob issues commands to the server to set the current library, call the program or go to the menu.

As stated earlier, limited users do not have the privilege of using a DataGate server job to fulfill arbitrary commands, so MobileRPGJob must be modified if you need to support limited users. These modifications involve the following:

  • Request that the Database connection be started without server support.
  • Avoid making the requests to establish the library and the call to programs and menus.
  • Remove the fields referring to program, menu and library from the SignOn.aspx page.
  • Ensure the DataGate library is in the library list for the user's job.

Database Connection without Server Support

Before the connection to the Database is established, you can set the type of server facilities you will have on the DataGate server job. You can request full server support, or choose not to start the server facilities. You establish this via the ServerSupport property of the Database object (AVRRuntime.Database class).

If your application is meant to be accessed by limited users, set the property to the DoNotStart value as shown below. You must also provide the code page to be used by the terminal emulator.

     myDatabase.ServerSupport = AVRRuntime.ServerSupport.DoNotStart
    myDatabase.DefaultJobCodePageID = 37
    CONNECT myDatabase
						

For more information on the server support of database connections please see the Limited Capability Users topic.

Avoid Server Requests

In the MobileRPGJob class, after the logon screen has been presented to the user, the code checks to see if a library, program or menu were entered and it issues the corresponding commands to the server to change the current library and/or invoke the program or menu. This code must be removed.

Here is an example of a modified version of the logon and ExecuteStartupProgram methods of the class in C#:

private void logon()
{
    LogonInfo logonInfo = new LogonInfo();
    myDatabase = new AVRRuntime.Database( "", 
                                  AVRRuntime.VirtualTerminal.MonarchWeb, 
                                  AVRRuntime.OpenAccessDspF.MobileRPG );
    myDatabase.ServerSupport = AVRRuntime.ServerSupport.DoNotStart;
    myDatabase.DefaultJobCodePageID = 37;
    while( true )
    {
        promptLogon( logonInfo );

        myDatabase.Server = logonInfo.Server;
        myDatabase.User = logonInfo.User;
        myDatabase.Password = logonInfo.Password;
        myDatabase.Port = logonInfo.Port;

        try
        {
            myDatabase.Open();
            break;
        }
        catch( dgException dgEx )
        {
            logonInfo.Message = dgEx.Message;
        }
    }
}

override protected void ExecuteStartupProgram()
{
    logon( );
}

Hide fields from SignOn.aspx

Since the library, program and menu fields are useless for limited users they should be removed or hidden from the sign-on page so that end user doesn't get the false impression that they can influence the initial behavior of the application.

The easiest fix is to hide these fields and constants by setting their VisibleCondition property to *False. Here is a fragment of the page's markup showing this change:

<mdf:DdsConstant id="DdsConstant3" runat="server" Text="Program/procedure"
	VisibleCondition="*False" CssClass="DdsConstant"
	style=" POSITION: absolute; LEFT: 150px; TOP: 220px;" />

<mdf:DdsCharField id="RSignon_Program" runat="server" VisibleCondition="*False"
	CssClass="DdsCharField" Length="10" Lower="True" 
	style=" POSITION: absolute; LEFT: 300px; TOP: 220px;" Alias="Program" 
	Usage="Both" VirtualRowCol="10,30" 
	Width="200px" />

<mdf:DdsConstant id="DdsConstant4" runat="server" Text="Menu" 
	VisibleCondition="*False" CssClass="DdsConstant"
	style=" POSITION: absolute; LEFT: 150px; TOP: 243px;" />

<mdf:DdsCharField id="RSignon_Menu" runat="server" VisibleCondition="*False"
	CssClass="DdsCharField" Length="10" Lower="True" 
	style=" POSITION: absolute; LEFT: 300px; TOP: 243px;" Alias="Menu"  
	Usage="Both" VirtualRowCol="11,30" Width="200px" />

<mdf:DdsConstant id="DdsConstant5" runat="server" Text="Current Library"
	VisibleCondition="*False" CssClass="DdsConstant"
	style=" POSITION: absolute; LEFT: 150px; TOP: 265px; width:100px" />

<mdf:DdsCharField id="RSignon_Library" runat="server" VisibleCondition="*False"
	CssClass="DdsCharField" Length="10" Lower="True" 
	style=" POSITION: absolute; LEFT: 300px; TOP: 266px;" Alias="Library" 
	Usage="Both" VirtualRowCol="12,30" Width="200px"  />	
					

Putting Datagate Library in the Library List

When an RPG program that has been enhanced with MOBILERPG is invoked, the DataGate installation library must be locatable via the library list. There are various ways of ensuring this happens, some of them are:

  • Add DataGate's library to the system portion of the library list (system value QSYSLIBL).
  • Associate the library with the user profile.
  • Programatically add the library using the ADDLIBLE command.