Skip to main content development
   toolset
 
  Easy400   |       iSeries home
Public-Source
 
Introduction
Tutorial
Examples
FAQ
Index
Download
 
 

 
2.5 - Message handling


Message support procedures may help in standardizing the display of error messages across WEB applications.

The strategy supported is made of two pieces

  1. standardization of message styles through the use of a given set of Cascade Stile Sheet (CSS) styles
  2. standardization of message levels via predefined HTML sections

As an example, take a look at the following message box:

 
 
Messages:
- This is a level 1 message
- This is another level 1 message
- This is a level 2 message
- This is a level 3 message
 
 

That can be implemented

  1. through the following CSS and the following sections
    /$top
        Content-type: text/html
    
        <HTML>
          <HEAD>
            <TITLE>Title of this page</TITLE>
                 <style TYPE="text/css">
                 <!--
                 .messagestart, .message1, .message2, .message3  {color: black;
                    font-weight: normal; font-family: verdana, arial, helvetica, helv;}
                 .messagestart { font-size: 16pt; }
                 .message1 { margin-left: 20px; text-indent: -12px; font-size: 12pt }
                 .message2 { margin-left: 40px; text-indent: -10px; font-size: 10pt }
                 .message3 { margin-left: 60px; text-indent: -10px; font-size: 10pt }
                 -->
                 </style>
          </HEAD>
        <BODY>
              <!--  ... etc. ... -->
        /$MsgStart
        <table cellspacing=0 cellpadding=1 bgcolor=black><tr><td>
        <table cellspacing=0 cellpadding=0 bgcolor=pink width="100%"><tr><td>
        <table cellspacing=0 cellpadding=0 bgcolor=pink width="100%"><tr><td>
        <tr><td height=10 colspan=3> </td></tr>
        <tr><td width=10> </td><td>
                <div class=messagestart>Messages:</div>
        /$MsgL1
                <div class=message1>- /%msgtext%/</div>
        /$MsgL2
                <div class=message2>- /%msgtext%/</div>
        /$MsgL3
                <div class=message3>- /%msgtext%/</div>
        /$MsgEnd
        </td><td width=10> </td></tr>
        <tr><td height=10 colspan=3> </td></tr>
        </table></td></tr></table></td></tr></table>
  2. and using the message support procedures explained hereafter
(you may see this applied in the following example).

Message support procedures
  1.  QCfgMsgs  - Configure messages
    Use this procedure to set up section names and variable names for use by the QWrtMsgs procedure. All parameters are optional.

    The following parameters may be passed:

    1. (char 30) name of the externally described HTML's field to receive the message text. The default is msgtext.
    2. (char 50) name of the HTML section used to start the error message output. The default is msgstart.
    3. (char 50) name of the HTML section used to end the error message output. The default is msgend.
    4. (char 50) name of the HTML section used to output level 1 error messages. It should include the msgtext output variable. The default is msgl1.
    5. (char 50) name of the HTML section used to output level 2 error messages. It should include the msgtext output variable. The default is msgl2.
    6. (char 50) name of the HTML section used to output level 3 error messages. It should include the msgtext output variable. The default is msgl3.

    Example for using the default values:
                ...         ...         ...
           SPECIAL-NAMES.
                 copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                ...         ...         ...
          * Configure messages (use default values)
               call 'QCFGMSGS'.


  2.  QClrMsgs  - Clear messages
    Use this procedure to clear all messages previously loaded into service program arrays through procedure QADDMSG. No parameters are needed.

    Example:
                ...         ...         ...
           SPECIAL-NAMES.
                 copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                ...         ...         ...
          * Clear all previous messages
               call 'QCLRMSGS'.


  3.  QAddMsg  - Add a messages
    Use this procedure to load a new message into service program arrays. All messages loaded can then be written out to the HTML buffer through procedure QWRTMSGS.

    Input parameters:

    1. message text (char 200)
    2. message level (numeric): Value 1, 2, or 3. Default is 1.
    Returned value:
    • return code (numeric):
      • 0 = no problems
      • 1 = array full
      • 2 = invalid level (however the message is filed with level 1)

    Example:
                ...         ...         ...
           SPECIAL-NAMES.
                 copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                ...         ...         ...
          * Variables for HTML messages
               05     retcode             PIC  S9(9) comp-4.
               05     msglvl              PIC  S9(9) comp-4.
               05     msgtxt              PIC  X(200).
                ...         ...         ...
          * Add level 2 message
               compute msglvl = 2.
               move 'This is a level 2 message' to msgtxt.
               call 'QADDMSG' using msgtxt msglvl
                              returning into retcode.
        


  4.  QGetMsgCnt  - Get message count
    Use this procedure to retrieve the number of messages loaded so far. It can be useful to avoid using procedure QWRTMSGS when no messages have been loaded.

    Returned value:

    • message count (numeric)

    Example:
                ...         ...         ...
           SPECIAL-NAMES.
                 copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                ...         ...         ...
          * Variables for HTML messages
               05     msgcnt              PIC  S9(9) comp-4.
                ...         ...         ...
          * Retrieve the number of messages loaded so far
               call 'QGETMSGCNT' returning into msgcnt.
        


  5.  QWrtMsgs  - Write messages
    Use this procedure write to the HTML output buffer all the messages previoulsy loaded into service program arrays through procedure QADDMSG. No parameters are needed.

    Example:
                ...         ...         ...
           SPECIAL-NAMES.
                 copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                ...         ...         ...
          * Write out all messages
               call 'QWRTMSGS'.

    Note 1. If no messages were loaded, nothing is written out.
    Note 2. If procedure QCFGMSG did set the message section names to blank, nothing is written out.




    Contact