|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.jdesktop.html.form.Forms
public final class Forms extends Object
Utility class used for automatically creating a Form instance directly from an HTTP Response. Also contains utility methods for encoding form bodies for transmission, and other Form related functions.
Because HTML is not always well formed, this utility class does not support parsing HTML directly. Rather, it supports parsing HTML documents which have been previously made well-formed. It is then parsed just as any XML document.
Those methods which take a Response directly will take the response text and pass it through some routines to attempt to clean the HTML. If this fails, parsing will fail.
If you want to run your own cleanup routines, do so prior to calling one of the methods which take a SimpleDocument.
| Constructor Summary | |
private Forms()
|
|
| Method Summary | |
|---|---|
static Form
|
getForm(SimpleDocument dom, String baseUrl, String expression)
Gets a Form from the given DOM Document, based on the given XPath expression. |
static Form
|
getFormById(SimpleDocument dom, String baseUrl, String formId)
Gets a Form from the given DOM Document by finding the Form in
the document which has an id attribute equal to the given |
static Form
|
getFormByIndex(SimpleDocument dom, String baseUrl, int index)
Gets a Form from the given DOM Document by finding the
|
static Form
|
getFormByName(SimpleDocument dom, String baseUrl, String name)
Gets a Form from the given DOM Document by finding the Form in
the document which has a name attribute equal to the given |
static Parameter[]
|
getParameters(Form f)
Given a Form, return the Parameters that would be used to construct an HTTP request for this form. |
private static boolean
|
isValidUrl(String url)
|
static Response
|
submit(Form f, Session session)
Submits this form using the given Session. |
| Methods inherited from class Object | |
|---|---|
| wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Constructor Detail |
|---|
private Forms()
| Method Detail |
|---|
public static Form getForm(SimpleDocument dom, String baseUrl, String expression)
dom - the DOM Document to parse the HTML Form from.baseUrl - the baseUrl which generated this DOM document. This is required
if you later want to submit the HTML Form, since url's in the
Form may be relative.expression - the XPath expression to use to find the Form tag to be parsed.
public static Form getFormById(SimpleDocument dom, String baseUrl, String formId)
id
parameter.
dom - the DOM Document to parse the HTML Form from.baseUrl - the baseUrl which generated this DOM document. This is required
if you later want to submit the HTML Form, since url's in the
Form may be relative.id - the id of the Form element within the DOM which should be parsed
public static Form getFormByIndex(SimpleDocument dom, String baseUrl, int index)
index'th Form in the document.
dom - the DOM Document to parse the HTML Form from.baseUrl - the baseUrl which generated this DOM document. This is required
if you later want to submit the HTML Form, since url's in the
Form may be relative.index - the index of the Form to parse. For example, if there are 3 <form>
tags in the document, and index is 2, then the second form will be
selected. index is 1 based.
public static Form getFormByName(SimpleDocument dom, String baseUrl, String name)
name
parameter.
dom - the DOM Document to parse the HTML Form from.baseUrl - the baseUrl which generated this DOM document. This is required
if you later want to submit the HTML Form, since url's in the
Form may be relative.name - the name of the Form element within the DOM which should be parsed
public static Parameter[] getParameters(Form f)
f - the Form to use. If null, an empty parameter array is returned.
private static boolean isValidUrl(String url)
public static Response submit(Form f, Session session)
session - the Session to execute this form through. This must not be
null.
Groovy Documentation