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

Actions Documentation

Add(Libraries.Web.Page.Attribute attribute)

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

Parameters

Example


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)

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

Parameters

  • text name: The name of the attribute functions as a key. For example, in a link, we might have a "src" and an actual address, like google.com. In this case, the name would be equivalent to the src.
  • text value: As an example of link, imagine we have a value of "src" and an actual address, like google.com. In this case, the value would be equivalent to google.com.

Example


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

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

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

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

Parameters

Return

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

Example

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

GenerateAttributes()

This action returns a text description of all attributes stored.

Return

text:

Example


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

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

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.

Parameters

  • text name

Return

Libraries.Web.Page.Attribute:

Example


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")

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.

Parameters

  • text name: The key value in this case is described in more detail in the documentation for this class's Add actions.

Return

text:

Example


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")

GetAttributes()

Returns a list of all attributes on the system.

Return

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

Example



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

AttributeAccepter accept
Attributes attributes = accept:GetAttributes()

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetIterator()

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

Return

Libraries.Containers.Iterator:

Example


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

GetNumberOfAttributes()

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

Return

integer:

Example


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

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

GetOnBlur()

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

Return

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

Example



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

FormAttributeAccepter accept
Attribute attribute = accept:GetOnBlur()

GetOnChange()

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

Return

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

Example



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

FormAttributeAccepter accept
Attribute attribute = accept:GetOnChange()

GetOnContextMenu()

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

Return

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

Example



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

FormAttributeAccepter accept
Attribute attribute = accept:GetOnContextMenu()

GetOnFocus()

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

Return

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

Example



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

FormAttributeAccepter accept
Attribute attribute = accept:GetOnFocus()

GetOnFormChange()

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

Return

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

Example



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

FormAttributeAccepter accept
Attribute attribute = accept:GetOnFormChange()

GetOnFormInput()

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

Return

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

Example



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

FormAttributeAccepter accept
Attribute attribute = accept:GetOnFormInput()

GetOnInput()

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

Return

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

Example



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

FormAttributeAccepter accept
Attribute attribute = accept:GetOnInput()

GetOnInvalid()

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

Return

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

Example



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

FormAttributeAccepter accept
Attribute attribute = accept:GetOnInvalid()

GetOnSelect()

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

Return

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

Example



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

FormAttributeAccepter accept
Attribute attribute = accept:GetOnSelect()

GetOnSubmit()

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

Return

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

Example



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

FormAttributeAccepter accept
Attribute attribute = accept:GetOnSubmit()

HasAttribute(text name)

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

Parameters

  • text name: The key value in this case is described in more detail in the documentation for this class's Add actions.

Return

boolean:

Example


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")

RemoveAttribute(text name)

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

Parameters

  • text name: The name of the attribute that should be removed.

Return

Libraries.Web.Page.Attribute:

Example


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")

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.

Parameters

  • text value: The current onblur script.

Example



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

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

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.

Parameters

  • text value: The current OnChange script.

Example



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

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

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.

Parameters

  • text value: The current OnContextMenu script.

Example



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

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

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.

Parameters

  • text value: The current OnFocus script.

Example



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

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

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.

Parameters

  • text value: The current OnFormChange script.

Example



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

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

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.

Parameters

  • text value: The current OnFormInput script.

Example



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

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

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.

Parameters

  • text value: The current OnInput script.

Example



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

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

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.

Parameters

  • text value: The current OnInvalid script.

Example



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

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

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.

Parameters

  • text value: The current OnSelect script.

Example



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

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

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.

Parameters

  • text value: The current OnSubmit script.

Example



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

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