
org.enhydra.xml.xhtml.dom.xerces.XHTMLSelectElementImpl Maven / Gradle / Ivy
The newest version!
/*
* Enhydra Java Application Server Project
*
* The contents of this file are subject to the Enhydra Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License on
* the Enhydra web site ( http://www.enhydra.org/ ).
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific terms governing rights and limitations
* under the License.
*
* The Initial Developer of the Original Code is DigitalSesame
* Portions created by DigitalSesame are Copyright (C) 1997-2000 DigitalSesame
* All Rights Reserved.
*
* Contributor(s):
* Rex Tsai
* David Li
*
* $Id: XHTMLSelectElementImpl.java,v 1.6 2005/01/26 08:29:24 jkjome Exp $
*/
package org.enhydra.xml.xhtml.dom.xerces;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.html.HTMLCollection;
import org.w3c.dom.html.HTMLElement;
import org.w3c.dom.html.HTMLOptionElement;
public class XHTMLSelectElementImpl
extends XHTMLElementImpl
implements org.enhydra.xml.xhtml.dom.XHTMLSelectElement
{
public XHTMLSelectElementImpl (XHTMLDocumentBase owner, String namespaceURI, String tagName) {
super( owner, namespaceURI, tagName);
}
/*
* Explicit implementation of getChildNodes() to avoid problems with
* overriding the getLength() method hidden in the super class.
*/
public NodeList getChildNodes() {
return getChildNodesUnoptimized();
}
public void setId (String newValue) {
setAttribute("id", newValue);
}
public String getId () {
return getAttribute ("id");
}
public void setLang (String newValue) {
setAttribute("lang", newValue);
}
public String getLang () {
return getAttribute ("lang");
}
public void setDir (String newValue) {
setAttribute("dir", newValue);
}
public String getDir () {
return getAttribute ("dir");
}
public void setClassName (String newValue) {
setAttribute("class", newValue);
}
public String getClassName () {
return getAttribute ("class");
}
public void setTitle (String newValue) {
setAttribute("title", newValue);
}
public String getTitle () {
return getAttribute ("title");
}
public void setName (String newValue) {
setAttribute("name", newValue);
}
public String getName () {
return getAttribute ("name");
}
public void setValue (String newValue) {
setAttribute("value", newValue);
}
public String getValue () {
return getAttribute ("value");
}
public void setType (String newValue) {
setAttribute("type", newValue);
}
public String getType () {
return getAttribute ("type");
}
public void setSize (int newValue) {
setAttribute("size", newValue);
}
public int getSize () {
return getIntAttribute ("size");
}
public void setTabIndex (int newValue) {
setAttribute("tabindex", newValue);
}
public int getTabIndex () {
return getIntAttribute ("tabindex");
}
public void setDisabled (boolean newValue) {
setAttribute("disabled", newValue);
}
public boolean getDisabled () {
return getBooleanAttribute("disabled");
}
public void setMultiple (boolean newValue) {
setAttribute("multiple", newValue);
}
public boolean getMultiple () {
return getBooleanAttribute("multiple");
}
public void setOnKeyUp (String newValue) {
setAttribute("onkeyup", newValue);
}
public String getOnKeyUp () {
return getAttribute ("onkeyup");
}
public void setStyle (String newValue) {
setAttribute("style", newValue);
}
public String getStyle () {
return getAttribute ("style");
}
public void setOnMouseDown (String newValue) {
setAttribute("onmousedown", newValue);
}
public String getOnMouseDown () {
return getAttribute ("onmousedown");
}
public void setOnKeyPress (String newValue) {
setAttribute("onkeypress", newValue);
}
public String getOnKeyPress () {
return getAttribute ("onkeypress");
}
public void setOnDblClick (String newValue) {
setAttribute("ondblclick", newValue);
}
public String getOnDblClick () {
return getAttribute ("ondblclick");
}
public void setOnKeyDown (String newValue) {
setAttribute("onkeydown", newValue);
}
public String getOnKeyDown () {
return getAttribute ("onkeydown");
}
public void setOnMouseMove (String newValue) {
setAttribute("onmousemove", newValue);
}
public String getOnMouseMove () {
return getAttribute ("onmousemove");
}
public void setOnMouseUp (String newValue) {
setAttribute("onmouseup", newValue);
}
public String getOnMouseUp () {
return getAttribute ("onmouseup");
}
public void setXmlLang (String newValue) {
setAttribute("xml:lang", newValue);
}
public String getXmlLang () {
return getAttribute ("xml:lang");
}
public void setOnMouseOut (String newValue) {
setAttribute("onmouseout", newValue);
}
public String getOnMouseOut () {
return getAttribute ("onmouseout");
}
public void setOnClick (String newValue) {
setAttribute("onclick", newValue);
}
public String getOnClick () {
return getAttribute ("onclick");
}
public void setOnMouseOver (String newValue) {
setAttribute("onmouseover", newValue);
}
public String getOnMouseOver () {
return getAttribute ("onmouseover");
}
public void setOnBlur (String newValue) {
setAttribute("onblur", newValue);
}
public String getOnBlur () {
return getAttribute ("onblur");
}
public void setOnFocus (String newValue) {
setAttribute("onfocus", newValue);
}
public String getOnFocus () {
return getAttribute ("onfocus");
}
public void setOnChange (String newValue) {
setAttribute("onchange", newValue);
}
public String getOnChange () {
return getAttribute ("onchange");
}
;
public int getLength() {
return getOptions().getLength();
}
public int getSelectedIndex() {
NodeList options;
int i;
// Use getElementsByTagName() which creates a snapshot of all the
// OPTION elements under this SELECT. Access to the returned NodeList
// is very fast and the snapshot solves many synchronization problems.
// Locate the first selected OPTION and return its index. Note that
// the OPTION might be under an OPTGROUP.
options = getElementsByTagName( "OPTION" );
for ( i = 0 ; i < options.getLength() ; ++i )
if ( ( (HTMLOptionElement) options.item( i ) ).getSelected() )
return i;
return -1;
}
public void setSelectedIndex( int selectedIndex ) {
NodeList options;
int i;
// Use getElementsByTagName() which creates a snapshot of all the
// OPTION elements under this SELECT. Access to the returned NodeList
// is very fast and the snapshot solves many synchronization problems.
// Change the select so all OPTIONs are off, except for the
// selectIndex-th one.
options = getElementsByTagName( "OPTION" );
for ( i = 0 ; i < options.getLength() ; ++i )
( (XHTMLOptionElementImpl) options.item( i ) ).setSelected( i == selectedIndex );
}
public HTMLCollection getOptions() {
if ( _options == null )
_options = new XHTMLCollectionImpl( this, XHTMLCollectionImpl.OPTION );
return _options;
}
public void add( HTMLElement element, HTMLElement before ) {
insertBefore( element, before );
}
public void remove( int index ) {
NodeList options;
Node removed;
// Use getElementsByTagName() which creates a snapshot of all the
// OPTION elements under this SELECT. Access to the returned NodeList
// is very fast and the snapshot solves many synchronization problems.
// Remove the indexed OPTION from it's parent, this might be this
// SELECT or an OPTGROUP.
options = getElementsByTagName( "OPTION" );
removed = options.item( index );
if ( removed != null )
removed.getParentNode().removeChild ( removed );
}
public void blur() {
// No scripting in server-side DOM. This method is moot.
}
public void focus() {
// No scripting in server-side DOM. This method is moot.
}
private HTMLCollection _options;
;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy