ScreenOutputCallback (Web property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
No edit summary
 
Line 1: Line 1:
{{Template:Web:ScreenOutputCallback subtitle}}
{{Template:Web:ScreenOutputCallback subtitle}}
 
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]].
This page is [[under construction]].
==Syntax==
==Syntax==
{{Template:Web:ScreenOutputCallback syntax}}
{{Template:Web:ScreenOutputCallback syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%webScreenCallback</th><td><var>WebScreenCallback</var> object</td></tr>
<tr><th>%webScreenCallback</th><td><var>[[WebScreenCallback type|WebScreenCallback]]</var> object</td></tr>
<tr><th nowrap="true"><var>%(Web)</var></th>
<tr><th nowrap="true"><var>%(Web)</var></th>
<td>The class name in parentheses denotes a shared method. <var>ScreenOutputCallback</var> can also be invoked via a <var>Web</var> object variable, which may be <var>Null</var>.</td></tr>
<td>The class name in parentheses denotes a shared method. <var>ScreenOutputCallback</var> can also be invoked via a <var>Web</var> object variable, which may be <var>Null</var>.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<li>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 (XmlDoc/XmlNode function)|LoadXml]]) using the CrPreserve option. The ScreenOutputCallback function can also change response header parameters.</li>
<li>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.</li>
<li>If the ScreenOutputCallback returns a False or a null, an exception will be thrown before the page is sent to the client.</li>
<li>The ScreenOutputCallback can, of course, also throw an exception.</li>
<li>ScreenOutputCallback has no effect on non-web threads and has virtually no overhead on non-web threads.</li>
<li>There can only be one ScreenOutputCallback active in any request and a ScreenOutputCallback is only active for the life of the request.</li>
</ul>
==Examples==
==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:
<p class="code">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 &pi;":u
%doc:webSend
return true
end function
%(web):screenOutputCallback = fixer
$web_screen(, 'XMLSCREENFIELD')
...
</p>
==See also==
==See also==
{{Template:Web:ScreenOutputCallback footer}}
{{Template:Web:ScreenOutputCallback footer}}

Latest revision as of 05:29, 19 December 2014

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