Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.lobobrowser.html.test.SimpleHtmlRendererContext
SimpleHtmlRendererContext
class implements
the HtmlRendererContext
interface.
Note that this class provides rudimentary implementations
of most callback methods. Overridding some of the methods
in this class will usually be necessary in a professional application.
Constructor Summary | |
| |
| |
|
Method Summary | |
void |
|
void |
|
void |
|
void |
|
boolean |
|
BrowserFrame | |
protected HTMLDocumentImpl |
|
void |
|
void |
|
void |
|
String |
|
protected String |
|
HTMLCollection | |
HtmlObject |
|
String |
|
HtmlRendererContext | |
HtmlRendererContext | |
protected Proxy |
|
String |
|
String | |
HtmlRendererContext |
|
UserAgentContext |
|
boolean |
|
protected boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
HtmlRendererContext |
|
HtmlRendererContext |
|
String |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
protected void |
|
void |
|
void |
|
public SimpleHtmlRendererContext(HtmlPanel contextComponent)
Deprecated. Use constructor that takes
HtmlPanel
andUserAgentContext
Constructs a SimpleHtmlRendererContext.
- Parameters:
contextComponent
- The component that will render HTML.
public SimpleHtmlRendererContext(HtmlPanel contextComponent, HtmlRendererContext parentRcontext)
Constructs a SimpleHtmlRendererContext that is a child of another.
HtmlRendererContext
- Parameters:
contextComponent
- The component that will render HTML.parentRcontext
- The parent's renderer context.
public SimpleHtmlRendererContext(HtmlPanel contextComponent, UserAgentContext ucontext)
Constructs a SimpleHtmlRendererContext.
- Parameters:
contextComponent
- The component that will render HTML.
public void alert(String message)
Opens a simple message dialog.
- Specified by:
- alert in interface HtmlRendererContext
public void back()
It should navigate back one page. This implementation does nothing and should be overridden.
- Specified by:
- back in interface HtmlRendererContext
public void blur()
It should give up focus on the current browser window. This implementation does nothing and should be overridden.
- Specified by:
- blur in interface HtmlRendererContext
public void close()
It should close the current browser window. This implementation does nothing and should be overridden.
- Specified by:
- close in interface HtmlRendererContext
public boolean confirm(String message)
Opens a simple confirmation window.
- Specified by:
- confirm in interface HtmlRendererContext
public BrowserFrame createBrowserFrame()
- Specified by:
- createBrowserFrame in interface HtmlRendererContext
protected HTMLDocumentImpl createDocument(org.xml.sax.InputSource inputSource) throws IOException, org.xml.sax.SAXException
Creates a blank document instance. This method is invoked whenever navigation or form submission occur. It is provided so it can be overridden to create specialized document implmentations.
- Parameters:
inputSource
- The document input source.
public void error(String message)
public void error(String message, Throwable throwable)
public void focus()
It should request focus for the current browser window. This implementation does nothing and should be overridden.
- Specified by:
- focus in interface HtmlRendererContext
public String getDefaultStatus()
Should return true if and only if the current browser window is closed. This implementation returns false and should be overridden.
- Specified by:
- getDefaultStatus in interface HtmlRendererContext
protected String getDocumentCharset(URLConnection connection)
This method is invoked bysubmitForm(String, URL, String, String, FormInput[])
to determine the charset of a document. The charset is determined by looking at theContent-Type
header.
- Parameters:
connection
- A URL connection.
public HTMLCollection getFrames()
Gets a collection of current document frames, by querying the document currently held by the localHtmlPanel
instance.
- Specified by:
- getFrames in interface HtmlRendererContext
public HtmlObject getHtmlObject(HTMLElement element)
Returnsnull
. This method should be overridden to provide OBJECT, EMBED or APPLET functionality.
- Specified by:
- getHtmlObject in interface HtmlRendererContext
public String getName()
It should return the name of the browser window, if this renderer context is for the top frame in the window. This implementation returns a blank string, so it should be overridden.
- Specified by:
- getName in interface HtmlRendererContext
public HtmlRendererContext getOpener()
- Specified by:
- getOpener in interface HtmlRendererContext
public HtmlRendererContext getParent()
- Specified by:
- getParent in interface HtmlRendererContext
protected Proxy getProxy()
Gets the connection proxy used innavigate(URL,String)
. This implementation callsSimpleUserAgentContext.getProxy()
ifgetUserAgentContext()
returns an instance assignable toSimpleUserAgentContext
. The method may be overridden to provide a different proxy setting.
public String getSourceCode()
Gets the source code of the current HTML document.
public UserAgentContext getUserAgentContext()
If aUserAgentContext
instance was provided in the constructor, then that instance is returned. Otherwise, an instance ofSimpleUserAgentContext
is created and returned. The context returned by this method is used by local request facilities and other parts of the renderer.
- Specified by:
- getUserAgentContext in interface HtmlRendererContext
public boolean isClosed()
Should return true if and only if the current browser window is closed. This implementation returns false and should be overridden.
- Specified by:
- isClosed in interface HtmlRendererContext
protected boolean isNavigationAsynchronous()
Indicates whether navigation (viasubmitForm(String, URL, String, String, FormInput[])
) should be asynchronous. This overridable implementation returnstrue
.
public boolean isVisitedLink(HTMLLinkElement link)
Should be overridden to return true if the link has been visited.
- Specified by:
- isVisitedLink in interface HtmlRendererContext
public void linkClicked(HTMLElement linkNode, URL url, String target)
Implements the link click handler by invokingnavigate(URL,String)
.
- Specified by:
- linkClicked in interface HtmlRendererContext
public void navigate(String fullURL) throws java.net.MalformedURLException
Convenience method provided to allow loading a document into the renderer.
- Parameters:
fullURL
- The absolute URL of the document.
- See Also:
navigate(URL,String)
public void navigate(URL href, String target)
Implements simple navigation with incremental rendering by invokingsubmitForm(String, URL, String, String, FormInput[])
with aGET
request method.
- Specified by:
- navigate in interface HtmlRendererContext
public void onContextMenu(HTMLElement element, MouseEvent event)
This method must be overridden to implement a context menu.
public void onMouseOut(HTMLElement element, MouseEvent event)
This method can be overridden to receive notifications when the mouse leaves an element.
public void onMouseOver(HTMLElement element, MouseEvent event)
This method can be overridden to receive notifications when the mouse first enters an element.
public final HtmlRendererContext open(String url, String windowName, String windowFeatures, boolean replace)
Deprecated. Use
open(URL, String, String, boolean)
.
- Specified by:
- open in interface HtmlRendererContext
public HtmlRendererContext open(java.net.URL url, String windowName, String windowFeatures, boolean replace)
It should open a new browser window. This implementation does nothing and should be overridden.
- Parameters:
url
- The requested URL.windowName
- A window identifier.windowFeatures
- Window features specified in a format equivalent to that of window.open() in Javascript.replace
- Whether an existing window with the same name should be replaced.
public String prompt(String message, String inputDefault)
Shows a simple prompt dialog.
- Specified by:
- prompt in interface HtmlRendererContext
public void reload()
Implements reload as navigation to current URL. Override to implement a more robust reloading mechanism.
- Specified by:
- reload in interface HtmlRendererContext
public void scroll(int x, int y)
Changes the origin of the HTML block's scrollable area according to the position given. This method may be called outside of the GUI thread. The operation is scheduled immediately in that thread as needed.
- Specified by:
- scroll in interface HtmlRendererContext
- Parameters:
x
- The new x coordinate for the origin.y
- The new y coordinate for the origin.
public void setDefaultStatus(String message)
- Specified by:
- setDefaultStatus in interface HtmlRendererContext
public void setOpener(HtmlRendererContext opener)
- Specified by:
- setOpener in interface HtmlRendererContext
public void setStatus(String message)
- Specified by:
- setStatus in interface HtmlRendererContext
public void submitForm(String method, java.net.URL action, String target, String enctype, FormInput[] formInputs)
Implements simple navigation and form submission with incremental rendering and target processing, including frame lookup. Should be overridden to allow for more robust browser navigation and form submission. Notes:
- Document encoding is defined by
getDocumentCharset(URLConnection)
.- Caching is not implemented.
- Cookies are not implemented.
- Incremental rendering is not optimized for ignorable document change notifications.
- Other HTTP features are not implemented.
- The only form encoding type supported is
application/x-www-form-urlencoded
.- Navigation is normally asynchronous. See
isNavigationAsynchronous()
.
- See Also:
navigate(URL,String)
protected void submitFormSync(String method, java.net.URL action, String target, String enctype, FormInput[] formInputs) throws IOException, org.xml.sax.SAXException
Submits a form and/or navigates by making a synchronous request. This method is invoked bysubmitForm(String, URL, String, String, FormInput[])
.
- Parameters:
method
- The request method.action
- The action URL.target
- The target identifier.enctype
- The encoding type.formInputs
- The form inputs.
- See Also:
submitForm(String, URL, String, String, FormInput[])
public void warn(String message)
public void warn(String message, Throwable throwable)