Libraries.Web.Page.FormAttributeAccepter Documentation

The FormAttributeAccepter class is designed as a helper to ease adding and removing attributes from particular WebTag objects belonging to a form. While there is no harm in creating an object of this type, it is used most commonly by sub-classes that need to use attributes. The example for this class shows how to subclass the FormAttributeAccepter class.

Example Code

use Libraries.Web.Page.FormAttributeAccepter

class Button is FormAttributeAccepter, WebGenerator
    action Generate returns text
        text result = "<button " 
        Attributes attributes = parent:WebTag:GetAttributes()
        attributeText = attributes:Generate()
        result = result + attributeText + ">"
        result = result + me:GenerateNestedTags()
        result = result + "</button>"
        return result
    end
end

Inherits from: Libraries.Web.Page.AttributeAccepter, Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
Add(Libraries.Web.Page.Attribute attribute)This action adds an attribute to this object.
AddAttribute(text name, text value)This action adds an attribute to this object.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns a CompareResult.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GenerateAttributes()This action returns a text description of all attributes stored.
GetAttribute(text name)This action returns an attribute from this object's Attributes object.
GetAttributeValue(text name)This action returns an attribute from this object's Attributes object.
GetAttributes()Returns a list of all attributes on the system.
GetHashCode()This action gets the hash code for an object.
GetIterator()This action returns an iterator of all attributes stored in this object.
GetNumberOfAttributes()This action returns the number of attributes that are currently stored in this object.
GetOnBlur()Returns the onblur attribute.
GetOnChange()Returns the OnChange attribute.
GetOnContextMenu()Returns the OnContextMenu attribute.
GetOnFocus()Returns the OnFocus attribute.
GetOnFormChange()Returns the OnFormChange attribute.
GetOnFormInput()Returns the OnFormInput attribute.
GetOnInput()Returns the OnInput attribute.
GetOnInvalid()Returns the OnInvalid attribute.
GetOnSelect()Returns the OnSelect attribute.
GetOnSubmit()Returns the OnSubmit attribute.
HasAttribute(text name)This action returns whether or not an attribute exists for the key passed in as a parameter.
RemoveAttribute(text name)This action removes an attribute with a particular key.
SetOnBlur(text value)Sets the onblur attribute.
SetOnChange(text value)Sets the OnChange attribute.
SetOnContextMenu(text value)Sets the OnContextMenu attribute.
SetOnFocus(text value)Sets the OnFocus attribute.
SetOnFormChange(text value)Sets the OnFormChange attribute.
SetOnFormInput(text value)Sets the OnFormInput attribute.
SetOnInput(text value)Sets the OnInput attribute.
SetOnInvalid(text value)Sets the OnInvalid attribute.
SetOnSelect(text value)Sets the OnSelect attribute.
SetOnSubmit(text value)Sets the OnSubmit attribute.

Actions Documentation

Add(Libraries.Web.Page.Attribute attribute)

This action adds an attribute to this object. If an attribute with the same name as

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        Attribute attribute
        attribute:SetName("src")
        attribute:SetValue("http://www.google.com")

        AttributeAccepter accept
        accept:Add(attribute)

Parameters

AddAttribute(text name, text value)

This action adds an attribute to this object. This action is a helper action, which essentially does the same thing as the Add(Attribute) action. If an attribute with the same name as

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")

Parameters

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.

Example Code

use Libraries.Language.Support.CompareResult
        Object o
        Object t
        CompareResult result = o:Compare(t)

Parameters

Return

Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Example Code

use Libraries.Language.Object
        use Libraries.Language.Types.Text
        Object o
        Text t
        boolean result = o:Equals(t)

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

GenerateAttributes()

This action returns a text description of all attributes stored.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")
        text result = accept:GenerateAttributes()

Return

text:

GetAttribute(text name)

This action returns an attribute from this object's Attributes object. If no attribute exists for a given key, this action returns undefined.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        //as we have not set any attribute, this would
        //return undefined
        Attribute attribute = accept:GetAttribute("src")

Parameters

Return

Libraries.Web.Page.Attribute:

GetAttributeValue(text name)

This action returns an attribute from this object's Attributes object. If no attribute exists for a given key, this action returns undefined.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")
        //This helper action would throw an error if "src" were not set.
        text value = accept:GetAttributeValue("src")

Parameters

Return

text:

GetAttributes()

Returns a list of all attributes on the system.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attributes

        AttributeAccepter accept
        Attributes attributes = accept:GetAttributes()

Return

Libraries.Web.Page.Attributes: The attributes class contains all of the attributes that have been set for this object.

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetIterator()

This action returns an iterator of all attributes stored in this object.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute
        use Libraries.Containers.Iterator

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")

        //output out all of the attributes
        Iterator<Attribute> it =  accept:GetIterator()
        repeat while it:HasNext()
            Attribute at = it:Next()
            output at:Generate()
        end

Return

Libraries.Containers.Iterator:

GetNumberOfAttributes()

This action returns the number of attributes that are currently stored in this object.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")
        integer num = accept:GetNumberOfAttributes()

Return

integer:

GetOnBlur()

Returns the onblur attribute. If the onblur attribute is enabled the form element has lost focus.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        Attribute attribute = accept:GetOnBlur()

Return

Libraries.Web.Page.Attribute: The current onblur attribute.

GetOnChange()

Returns the OnChange attribute. If the OnChange event occurs when a form elements state, text, or selection is changed.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        Attribute attribute = accept:GetOnChange()

Return

Libraries.Web.Page.Attribute: The current OnChange event attribute.

GetOnContextMenu()

Returns the OnContextMenu attribute. If the OnContextMenu specifies the script to run when a context menu is triggered.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        Attribute attribute = accept:GetOnContextMenu()

Return

Libraries.Web.Page.Attribute: The current OnContextMenu attribute.

GetOnFocus()

Returns the OnFocus attribute. If the OnFocus event occurs when a form element gains focus.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        Attribute attribute = accept:GetOnFocus()

Return

Libraries.Web.Page.Attribute: The current OnFocus event attribute.

GetOnFormChange()

Returns the OnFormChange attribute. If the OnFormChange stores the script to be run when a form change occurs.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        Attribute attribute = accept:GetOnFormChange()

Return

Libraries.Web.Page.Attribute: The current OnFormChange script attribute.

GetOnFormInput()

Returns the OnFormInput attribute. If the OnFormInput is triggered, by a form recieving input, the specified script will be run.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        Attribute attribute = accept:GetOnFormInput()

Return

Libraries.Web.Page.Attribute: The current OnFormInput event attribute.

GetOnInput()

Returns the OnInput attribute. If the OnInput is triggered, by a form element recieving input, the specified script will be run.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        Attribute attribute = accept:GetOnInput()

Return

Libraries.Web.Page.Attribute: The current OnInput event attribute.

GetOnInvalid()

Returns the OnInvalid attribute. If the OnInvalid is triggered, by a form element recieving invalid input, the specified script will be run.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        Attribute attribute = accept:GetOnInvalid()

Return

Libraries.Web.Page.Attribute: The current OnInvalid event attribute.

GetOnSelect()

Returns the OnSelect attribute. OnSelect is triggered by the selection of an elements text on the form.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        Attribute attribute = accept:GetOnSelect()

Return

Libraries.Web.Page.Attribute: The current OnSelect event attribute.

GetOnSubmit()

Returns the OnSubmit attribute. The OnSubmit is triggered by a submit action on the form.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        Attribute attribute = accept:GetOnSubmit()

Return

Libraries.Web.Page.Attribute: The current OnSubmit event attribute.

HasAttribute(text name)

This action returns whether or not an attribute exists for the key passed in as a parameter.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")
        //This helper action would throw an error if "src" were not set.
        boolean exists = accept:HasAttribute("src")

Parameters

Return

boolean:

RemoveAttribute(text name)

This action removes an attribute with a particular key. If that attribute does not exist, then this action returns undefined.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")
        //This helper action would throw an error if "src" were not set.
        accept:RemoveAttribute("src")

Parameters

Return

Libraries.Web.Page.Attribute:

SetOnBlur(text value)

Sets the onblur attribute. The onblur attribute is the script to be triggered when the onblur even occurs. OnBlur is fired the moment an element loses focus.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        accept:SetOnBlur("upperCase()")

Parameters

SetOnChange(text value)

Sets the OnChange attribute. The OnChange attribute is the script to be triggered when the OnChange event occurs. OnChange is fired the moment an element content is changed on a form.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        accept:SetOnChange("upperCase()")

Parameters

SetOnContextMenu(text value)

Sets the OnContextMenu attribute. The OnContextMenu attribute is the script to be triggered when the OnContextMenu event occurs. OnContextMenu is fired when a context menu is selected.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        accept:SetOnContextMenu("upperCase()")

Parameters

SetOnFocus(text value)

Sets the OnFocus attribute. The OnFocus attribute is the script to be triggered when the OnFocus event occurs. OnFocus is fired the moment an element gains focus.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        accept:SetOnFocus("upperCase()")

Parameters

SetOnFormChange(text value)

Sets the OnFormChange attribute. The OnFormChange attribute is the script to be triggered when the OnFormChange event occurs. OnFormChange is fired the moment the form is changed.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        accept:SetOnFormChange("upperCase()")

Parameters

SetOnFormInput(text value)

Sets the OnFormInput attribute. The OnFormInput attribute is the script to be triggered when the OnFormInput event occurs. OnFormInput is fired the moment the form is given input.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        accept:SetOnFormInput("upperCase()")

Parameters

SetOnInput(text value)

Sets the OnInput attribute. The OnInput attribute is the script to be triggered when the OnInput event occurs. OnInput is fired the moment a form element is given input.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        accept:SetOnInput("upperCase()")

Parameters

SetOnInvalid(text value)

Sets the OnInvalid attribute. The OnInvalid attribute is the script to be triggered when the OnInvalid event occurs. OnInvalid is fired the moment a form element is invalid.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        accept:SetOnInvalid("upperCase()")

Parameters

SetOnSelect(text value)

Sets the OnSelect attribute. The OnSelect attribute is the script to be triggered when the OnSelect event occurs. OnSelect is fired the moment a form elements text is selected.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        accept:SetOnSelect("upperCase()")

Parameters

SetOnSubmit(text value)

Sets the OnSubmit attribute. The OnSubmit attribute is the script to be triggered when the OnSubmit event occurs. OnSubmit is fired the moment a submit action occurs.

Example Code

use Libraries.Web.Page.FormAttributeAccepter
        use Libraries.Web.Page.Attribute

        FormAttributeAccepter accept
        accept:SetOnSubmit("upperCase()")

Parameters