When errors are found in the user's input, it is necessary to send one
or more messages to the browser.
Formatting and outputting such messages can be tedious,
repetitive, and error-prone.
You can more easyly perform this task,
using Mel's service program HTML message support.
Do the following:
- In the external HTML source member
create a set of sections to be used for message
outputting.
The standard set is available in
CGIDEV2/HTMLSRC member
TALK2.
The standard set must
- contain section names
MsgStart, MsgL1, MsgL2, MsgL3, MsgEnd
- a /%msgtext%/
variable must exist in sections
MsgL1, MsgL2, MsgL3
Look at the example from
TALK2:
/$top
Content-type: text/html
<HTML>
<HEAD>
<TITLE>Response To Talk To Us</TITLE>
<style TYPE="text/css">
<!--
.centeredtitle { color: Blue; font-weight: Bold; font-size: 24pt; text-align: center }
.emphasize {color: Blue; font-weight: Bold; }
.indent40 {margin-left: 40px; }
.messagestart, .message1, .message2, .message3 {color: Red; font-weight: Bold; }
.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
<div class=messagestart>Errors:</div>
/$MsgL1
<div class=message1>- /%msgtext%/</div>
/$MsgL2
<div class=message2>- /%msgtext%/</div>
/$MsgL3
<div class=message3>- /%msgtext%/</div>
/$MsgEnd
<div class=messagestart><hr></div> |
|
|
- Optionally you may use subprocedure
CfgMsgs
to override the default externally described HTML names:
- message text field name (msgtxt),
- starting section name (msgstart),
- level 1 section name (msgl1),
- level 2 section name (msgl2),
- level 3 section name (msgl3),
- ending section name (msgend).
- Use subprocedure
ClrMsgs
to clear the messages stored in the service program's arrays
and to set their count to zero
- Use subprocedure
AddMsg
to add a message's text and formatting level (1, 2, or 3)
to the service program's arrays
- Use subprocedure
GetMsgCnt
to retrieve the number of messages currently stored in the
service program's arrays.
It can be used to condition calling
WrtMsgs.
- Use subprocedure
WrtMsgs
to write the messages in the arrays to standard output.
If no messages are there, nothing is done.
For examples of using HTML messages, please look at
the source of RPG CGI program
TEMPLATE.
|