ScreenOutputCallback (Web property)

From m204wiki
Revision as of 05:29, 19 December 2014 by Alex (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Screen output callback function (Web class)

[Introduced in Model 204 7.6]

The WebScreenOutputCallback property is the property that contains the method that is called before a 3270 screen is sent to a client via Janus Web Legacy Support.

Syntax

%currentWebScreenCallback = %(Web):ScreenOutputCallback %(Web):ScreenOutputCallback = newWebScreenCallback

Syntax terms

%webScreenCallbackWebScreenCallback object
%(Web) The class name in parentheses denotes a shared method. ScreenOutputCallback can also be invoked via a Web object variable, which may be Null.

Usage notes

  • The ScreenOutputCallback function is called with no parameters. The function can examine and even modify the outgoing data by retrieving the data with the $Web_Output_Content function and then replacing the content after a $Web_Flush. The outgoing data is typically valid XML (whether XHTML Janus Web Legacy Support or pure Janus Web Legacy XML Support. If the intent is to modify outgoing XHTML, the XHTML should loaded (via LoadXml) using the CrPreserve option. The ScreenOutputCallback function can also change response header parameters.
  • If a ScreenOutputCallback function is to manipulate XHTML pages, it might be useful to set [XMLSCREENFIELD and NOXMLSCREENFIELD (JANUS DEFINE parameters)|XMLSCREENFIELD]] so that the HTML elements will be labeled with the names of the corresponding 3270 fields.
  • If the ScreenOutputCallback returns a False or a null, an exception will be thrown before the page is sent to the client.
  • The ScreenOutputCallback can, of course, also throw an exception.
  • ScreenOutputCallback has no effect on non-web threads and has virtually no overhead on non-web threads.
  • There can only be one ScreenOutputCallback active in any request and a ScreenOutputCallback is only active for the life of the request.

Examples

The following example changes the title of an outgoing XHTML page and sets the content-type to indicate utf-8 so that the pi character is displayed properly on all browsers:

local function fixer is boolean %doc is object xmlDoc %ls is longstring %doc = new %doc:loadXml($web_output_content, 'CrPreserve') $web_flush $web_type('text/html; charset=utf-8') %doc:value("/html/head/title") = "Motherhood and apple π":u %doc:webSend return true end function %(web):screenOutputCallback = fixer $web_screen(, 'XMLSCREENFIELD') ...

See also