org.directwebremoting.dwrp
Class HtmlScriptConduit

java.lang.Object
  extended by org.directwebremoting.dwrp.BaseScriptConduit
      extended by org.directwebremoting.dwrp.HtmlScriptConduit
All Implemented Interfaces:
ScriptConduit

public class HtmlScriptConduit
extends BaseScriptConduit

A ScriptConduit for use with HTML/SCRIPT wrapped Javascript output.

Scripts begin with an html and script tags. The scripts have been altered to include an 'execute-in-parent-context' wrapper.

If this conduit is used, the output should be directed to an iframe. No polling should be required.

This conduit works with IE 6/7 since the 4k buffer drawback does not prevent the execution of script elements.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Constructor Summary
HtmlScriptConduit(java.lang.String instanceId, java.lang.String batchId, java.lang.String documentDomain, ConverterManager converterManager, boolean jsonOutput)
          Simple ctor
 
Method Summary
 java.lang.String getOutboundMimeType()
          What mime type should we send to the browser for this data?
 void sendBeginChunk(java.io.PrintWriter out)
          Called before a each set of scripts that are to be sent.
 void sendBeginStream(java.io.PrintWriter out)
          Called when we are initially setting up the stream.
 void sendEndChunk(java.io.PrintWriter out)
          Called after each set of scripts when they have been sent.
 void sendEndStream(java.io.PrintWriter out, int timetoNextPoll)
          Called when we are shutting the stream down.
 void sendScript(java.io.PrintWriter out, java.lang.String script)
          Add a script to the list bound for remote execution.
 
Methods inherited from class org.directwebremoting.dwrp.BaseScriptConduit
setAccessLogLevel, setDebugScriptOutput
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlScriptConduit

public HtmlScriptConduit(java.lang.String instanceId,
                         java.lang.String batchId,
                         java.lang.String documentDomain,
                         ConverterManager converterManager,
                         boolean jsonOutput)
                  throws java.io.IOException
Simple ctor

Parameters:
batchId - The id of the batch that we are responding to
converterManager - How we convert objects to script
Throws:
java.io.IOException - If stream actions fail
Method Detail

getOutboundMimeType

public java.lang.String getOutboundMimeType()
Description copied from interface: ScriptConduit
What mime type should we send to the browser for this data?

Returns:
A mime-type

sendBeginStream

public void sendBeginStream(java.io.PrintWriter out)
Description copied from interface: ScriptConduit
Called when we are initially setting up the stream. This does not send any data to the client, just sets it up for data.

This method is always called exactly once in the lifetime of a conduit.


sendBeginChunk

public void sendBeginChunk(java.io.PrintWriter out)
Description copied from interface: ScriptConduit
Called before a each set of scripts that are to be sent.


sendScript

public void sendScript(java.io.PrintWriter out,
                       java.lang.String script)
                throws java.io.IOException
Description copied from interface: ScriptConduit
Add a script to the list bound for remote execution.

It is not an error to refuse to handle the script and return false, it just indicates that this ScriptConduit did not accept the script. If the ScriptConduit can no longer function then it should throw an exception and it will be assumed to be no longer useful. If you want to implement this method then you will probably be doing something like calling ServletOutputStream.print(String) and passing in the results of calling ScriptBufferUtil.createOutput().

script - The script to execute
Throws:
java.io.IOException - If this conduit is broken and should not be used

sendEndChunk

public void sendEndChunk(java.io.PrintWriter out)
Description copied from interface: ScriptConduit
Called after each set of scripts when they have been sent.


sendEndStream

public void sendEndStream(java.io.PrintWriter out,
                          int timetoNextPoll)
                   throws java.io.IOException
Description copied from interface: ScriptConduit
Called when we are shutting the stream down. The poll has finished, get the client to call us back

timetoNextPoll - How long before we tell the browser to come back?
Throws:
java.io.IOException

Copyright ยจ 2008