Class WebElement

  • All Implemented Interfaces:
    java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Settable

    public class WebElement
    extends StringAttribute
    Attribute containing information and methods for web elements, for example, HTML tags and content, as in <div> This is some HTML content </div> The full name including the _elementName is used as WebElement's web id. In an HTML page, elements that have ids are required to have globally unique ids. The _webName field is used for the WebElement's web name. Elements can have non-unique web names - this is done for example for radio buttons on web forms. http://solidlystated.com/scripting/html-difference-between-id-and-name/ http://stackoverflow.com/questions/1363693/do-input-field-names-have-to-be-unique-across-forms
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Elizabeth Latronico
    Pt.AcceptedRating:
    Red (ltrnc)
    Pt.ProposedRating:
    Red (ltrnc)
    • Field Detail

      • BODY

        public static final java.lang.String BODY
        A special constant indicating that the <body/> element should be the parent. The <head/> and <body/> tags of an HTML document do not typically have names. For example, almost no one writes <head name="head">, it's only <head/>. Therefore, the WebExporter will not be able to use the name to find the parent element.
        See Also:
        Constant Field Values
      • HEAD

        public static final java.lang.String HEAD
        A special constant indicating that the <head/> element should be the parent. The <head/> and <body/> tags of an HTML document do not typically have names. For example, almost no one writes <head name="head">, it's only <head/>. Therefore, the WebExporter will not be able to use the name to find the parent element.
        See Also:
        Constant Field Values
      • START

        public static final java.lang.String START
        Special constant indicating to put content in a div with the name "start" which occurs at the beginning of the HTML body.
        See Also:
        Constant Field Values
      • END

        public static final java.lang.String END
        Special constant indicating to put content in a div with the name "end" which occurs at the end of the HTML body.
        See Also:
        Constant Field Values
    • Method Detail

      • createWebElement

        public static WebElement createWebElement​(NamedObj container,
                                                  java.lang.String id,
                                                  java.lang.String webName)
                                           throws IllegalActionException
        Factory method for creating WebElements. Checks if there is an existing WebElement with the same id (Ptolemy name). If so, return it; if not create a new one. Sets persistent to false. Static so that any WebExportable may call it.
        Parameters:
        container - The container object for the WebElement
        id - The Ptolemy name for the WebElement (WebElement uses this as a unique id)
        webName - The web name of this WebElement
        Returns:
        The WebElement that was created (or that previously existed) with persistent set to false
        Throws:
        IllegalActionException - if the WebAttribute cannot be created (perhaps another Attribute exists with the requested name)
      • getParent

        public java.lang.String getParent()
        Return the name of the desired parent element, or the empty string if none.
        Returns:
        The name of the desired parent element, or the empty string if none.
        See Also:
        setParent(String)
      • getWebName

        public java.lang.String getWebName()
        Return the web name of this element; for example, "myElement" in <div name="myElement"/> in HTML.
        Returns:
        The web name of this element; for example, "myElement" in <div name="myElement"/> in HTML.
        See Also:
        setWebName(String)
      • setParent

        public void setParent​(java.lang.String parent)
        Set the name of the desired parent element. Can also be a special constant for tags that do not typically have names, like <head/> and <body/>.
        Parameters:
        parent - The name or special constant of the parent element.
        See Also:
        getParent()
      • setWebName

        public void setWebName​(java.lang.String webName)
        Set the web name of this element; for example, "myElement" in <div name="myElement"/> in HTML.
        Parameters:
        webName - The web name of this element; for example, "myElement" in <div name="myElement"/> in HTML.
        See Also:
        getWebName()