Just like the Cookie concept the HTMLForm concept is a helper concept.
Forms can be seen as a special kind of links. It's completeness depends
on the right parameters.
In this idea there are two simple ways to assist the navigation and
extraction process using forms. First, the most simple approach is to
use the HTMLForm concept to produce in the most simple way a complete
URL by providing all the desired parameters and attributes (the action
attribute and the name/value pairs). On the form initialized in this way
by invoking the getEncodedUrl method will get a fully composed and
encoded URL.
The second approach is most useful in automating the navigation process.
In the same mode as with the Cookies we can create particular HTMLForm
concepts (for different sites and with different parameters) and store
them in as a Series of HTMLForms in the mem://hyper/html/forms/ context.
The particular concepts stored in this way will be checked at navigation
by the http protocol handler and if a match is found between the
signatures of a form from a HTML page and one of our stored concepts the
it will be used as a valid navigation path.
Searching for "pepsi music" keyword on google and show results.
$myForm = HTMLForm.create()
$myForm.setURL("http://www.google.com/search")
$myForm.setMethod("GET")
$myForm.add("q", "pepsi music")
$myForm.add("btnG", "Google Search")
$page = HTMLPage.create( $myForm )
print $page/content
This example will show how you can looking for a Form and if you not have to store it.
$url = "http://192.168.1.22/oursite/"
$page from $url + "index.php"
# creating a simplex expression
$expr = Simplex.create( $url + "*" )
# looking for the stored forms using the simplex
$forms = HTMLForm.getStoredForms($expr)
# if we not have stored any form
if $forms@length == 0 then [
# pick up the form from the page
$form = $page.getForms/1
# change the value of "userid"
$idx = $form.indexOfKey("userid")
$form.remove("userid")
$form.insert ( $idx, "userid", "guest" )
# change the value of "passwd"
$idx = $form.indexOfKey("passwd")
$form.remove("passwd")
$form.insert ( $idx, "passwd", "guest" )
# storing the form
$form.storeForm]
Attributes inherited from: Map
|
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI |
|
Methods inherited from: Map
add, clear, containsKey, containsValue, getConceptElement, getConceptElements, getConceptElementField, getConceptElementFields, getKeyAt, getKeys, getValue, getValueAt, getValues, setIndex, indexOfKey, indexOfValue, insert, insert, nextKey, nextValue, remove |
|
Label: | encoding |
Type: | String |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
A function whose domain is the set of sequences of octets, and whose
range is the set of sequences of characters from a character repertoire;
that is, a sequence of octets and a character encoding scheme determines
a sequence of characters.
Label: | Has next |
Type: | Logical |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Specify whenever the index represents the last element of the series or not.
Label: | Has previous |
Type: | Logical |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Specify whenever the index represents the first element of the series or not.
Label: | id |
Type: | String |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Label: | Index |
Type: | Integer |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Specify the current position of the cursor in the HTMLForm, also used to
move the cursor at the wanted position. Initially the index is
positioned at the first element of the HTMLForm.
Label: | Length |
Type: | Integer |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Specify the number of items this HTMLForm contains.
Label: | method |
Type: | String |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Selects a method of accessing the action URI. The set of applicable
methods is a function of the scheme of the action URI of the form.
Label: | name |
Type: | name |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
The name of this HTMLForm.
Label: | target |
Type: | String |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Identifies the default window or frame to be used to display the result
that is opened by submit this form.
Label: | url |
Type: | String |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Is the URL of the query server to which the form contents will be
submitted; if this attribute is absent, then the current document URL
will be used.
Label: | Has next |
Type: | Logical |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Specify whenever the index represents the last element of the series or
not.
Label: | Has previous |
Type: | Logical |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Specify whenever the index represents the first element of the series or
not.
Label: | Index |
Type: | Integer |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Specify the current position of the cursor in the Map, also used to move
the cursor at the wanted position. Initially the index is positioned at
the first element of the map.
Label: | Length |
Type: | Integer |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
Specify the number of items this Map contains.
Parameters: |
$from : | An element concept to be loaded. |
|
Loads from an Element concept all elements and attributes to this
HTMLForm.
<code language="mn8">
<![CDATA[
$form = HTMLForm.create
$form.setURL("http://www.google.com/search")
$form.setEncoding("application/x-www-form-urlencoded")
$form.setMethod("GET")
$form.setName("form1")
$form.setTarget("mFrame")
$form.add("q", "html form")
$form.add("btnG", "Google Search")
$form.storeForm
$f typeof HTMLForm
$f.loadContent(HTMLForm.getStoredForms("http://www.google.com/search")/1/)
print $f
-- the result is --
HTMLForm
method: GET url: http://www.google.com/search name: form1
encoding: application/x-www-form-urlencoded target: mFrame
q html form
btnG Google Search
Parameters: |
$encoding : | The encoding to be set. |
|
Sets this HTMLForm encoding to the specified value.
$form = HTMLForm.create
$form.setURL("http://www.google.com/search")
$form.setEncoding("application/x-www-form-urlencoded")
$form.setMethod("GET")
$form.setName("form1")
$form.setTarget("mFrame")
$form.add("q", "html form")
$form.add("btnG", "Google Search")
$form.storeForm
print HTMLForm.getStoredForms("http://www.google.com/search")
-- the result is --
HTMLForm
method: GET url: http://www.google.com/search name: form1
encoding: application/x-www-form-urlencoded target: mFrame
q html form
btnG Google Search
Parameters: |
$method : | The method to be set. |
|
Sets this HTMLForm method to the specified value.
$form = HTMLForm.create
$form.setURL("http://www.google.com/search")
$form.setEncoding("application/x-www-form-urlencoded")
$form.setMethod("GET")
$form.setName("form1")
$form.setTarget("mFrame")
$form.add("q", "html form")
$form.add("btnG", "Google Search")
$form.storeForm
print HTMLForm.getStoredForms("http://www.google.com/search")
-- the result is --
HTMLForm
method: GET url: http://www.google.com/search name: form1
encoding: application/x-www-form-urlencoded target: mFrame
q html form
btnG Google Search
Parameters: |
$name : | The name to be set. |
|
Sets this HTMLForm name to the specified value.
$form = HTMLForm.create
$form.setURL("http://www.google.com/search")
$form.setEncoding("application/x-www-form-urlencoded")
$form.setMethod("GET")
$form.setName("form1")
$form.setTarget("mFrame")
$form.add("q", "html form")
$form.add("btnG", "Google Search")
$form.storeForm
print HTMLForm.getStoredForms("http://www.google.com/search")
-- the result is --
HTMLForm
method: GET url: http://www.google.com/search name: form1
encoding: application/x-www-form-urlencoded target: mFrame
q html form
btnG Google Search
Parameters: |
$target : | The target to be set. |
|
Sets this HTMLForm target to the specified value.
$form = HTMLForm.create
$form.setURL("http://www.google.com/search")
$form.setEncoding("application/x-www-form-urlencoded")
$form.setMethod("GET")
$form.setName("form1")
$form.setTarget("mFrame")
$form.add("q", "html form")
$form.add("btnG", "Google Search")
$form.storeForm
print HTMLForm.getStoredForms("http://www.google.com/search")
-- the result is --
HTMLForm
method: GET url: http://www.google.com/search name: form1
encoding: application/x-www-form-urlencoded target: mFrame
q html form
btnG Google Search
Sets this HTMLForm URL to the specified value.
$form = HTMLForm.create
$form.setURL("http://www.google.com/search")
$form.setEncoding("application/x-www-form-urlencoded")
$form.setMethod("GET")
$form.setName("form1")
$form.setTarget("mFrame")
$form.add("q", "html form")
$form.add("btnG", "Google Search")
$form.storeForm
print HTMLForm.getStoredForms("http://www.google.com/search")
-- the result is --
HTMLForm
method: GET url: http://www.google.com/search name: form1
encoding: application/x-www-form-urlencoded target: mFrame
q html form
btnG Google Search
Exceptions: |
badURLException :
(Error) | If can't save this form to specified location. |
Saves your form to your forms directory.
$form = HTMLForm.create
$form.setURL("http://www.google.com/search")
$form.setEncoding("application/x-www-form-urlencoded")
$form.setMethod("GET")
$form.setName("form1")
$form.setTarget("mFrame")
$form.add("q", "html form")
$form.add("btnG", "Google Search")
$form.storeForm
print HTMLForm.getStoredForms("http://www.google.com/search")
-- the result is --
HTMLForm
method: GET url: http://www.google.com/search name: form1
encoding: application/x-www-form-urlencoded target: mFrame
q html form
btnG Google Search
Parameters: |
$url : | URL for searching forms. |
|
Exceptions: |
badURLException :
(Error) | If can't get the host name or the path from the URL. |
Seaching for the forms with the specified URL attribute.
$form = HTMLForm.create
$form.setURL("http://www.google.com/search")
$form.setEncoding("application/x-www-form-urlencoded")
$form.setMethod("GET")
$form.setName("form1")
$form.setTarget("mFrame")
$form.add("q", "html form")
$form.add("btnG", "Google Search")
$form.storeForm
print HTMLForm.getStoredForms("http://www.google.com/search")
-- the result is --
HTMLForm
method: GET url: http://www.google.com/search name: form1
encoding: application/x-www-form-urlencoded target: mFrame
q html form
btnG Google Search
Parameters: |
$expr : | Expression (Simplex or Regexp) with pattern for searching forms. |
|
Seaching for the forms where the Expression matches is true.
$form = HTMLForm.create
$form.setURL("http://www.google.com/search")
$form.setEncoding("application/x-www-form-urlencoded")
$form.setMethod("GET")
$form.setName("form1")
$form.setTarget("mFrame")
$form.add("q", "html form")
$form.add("btnG", "Google Search")
$form.storeForm
print HTMLForm.getStoredForms(Simplex.create("*google*"))
-- the result is --
HTMLForm
method: GET url: http://www.google.com/search name: form1
encoding: application/x-www-form-urlencoded target: mFrame
q html form
btnG Google Search