Package org.w3c.dom.html

Examples of org.w3c.dom.html.HTMLOptionElement


            if (options != null)
            {
                int i = 0;
                for(Iterator<Node> it = options.iterator(); it.hasNext(); i++)
                {
                    HTMLOptionElement optElem = (HTMLOptionElement)it.next();
                    String opref = "elem.options[" + i + "]";
                    processUIControlProperty(optElem,opref,"selected",code,clientDoc);
                    if (revertJSChanges)
                        processUIControlProperty(optElem,opref,"value",code,clientDoc);
                }
View Full Code Here


        return (HTMLOptionElement)selectElem.getOptions().item(index);
    }

    public String getOptionText(int index)
    {
        HTMLOptionElement option = getOptionElement(index);
        if (option == null) return null;
        return option.getText();
    }
View Full Code Here

    {
        HTMLCollection col = selectElem.getOptions();
        int len = col.getLength();
        for(int i = 0; i < len; i++)
        {
            HTMLOptionElement option = (HTMLOptionElement)col.item(i);
            if (option.getText().equals(item))
                return i;
        }
        return -1;
    }
View Full Code Here

            {
                try
                {
                    Document doc = getItsNatDocument().getDocument();
                    int pos = Integer.parseInt(posElem.getValue());
                    HTMLOptionElement before = getOptionElement(pos);
                    HTMLOptionElement added = (HTMLOptionElement)doc.createElement("option");
                    added.appendChild(doc.createTextNode(newItem));
                    selectElem.add(added, before);
                    selectElem.setSelectedIndex(pos);
                }
                catch(NumberFormatException ex)
                {
View Full Code Here

        return (HTMLOptionElement)selectElem.getOptions().item(index);
    }

    public String getOptionText(int index)
    {
        HTMLOptionElement option = getOptionElement(index);
        if (option == null) return null;
        return option.getText();
    }
View Full Code Here

    {
        HTMLCollection col = selectElem.getOptions();
        int len = col.getLength();
        for(int i = 0; i < len; i++)
        {
            HTMLOptionElement option = (HTMLOptionElement)col.item(i);
            if (option.getText().equals(item))
                return i;
        }
        return -1;
    }
View Full Code Here

            msg.append("Changed selection: ");
            HTMLCollection col = selectElem.getOptions();
            int len = col.getLength();
            for(int i = 0; i < len; i++)
            {
                HTMLOptionElement option = (HTMLOptionElement)col.item(i);
                msg.append( option.getText() + " (" + option.getSelected() + ") " );
            }
            log(msg.toString());
        }
        else if (currentTarget == removeElem)
        {
            HTMLCollection col = selectElem.getOptions();
            int len = col.getLength();
            HTMLOptionElement[] toRemove = new HTMLOptionElement[len];
            for(int i = 0; i < len; i++)
            {
                HTMLOptionElement option = (HTMLOptionElement)col.item(i);
                if (option.getSelected())
                    toRemove[i] = option;
            }

            for(int i = 0; i < len; i++)
            {
                HTMLOptionElement option = toRemove[i];
                if (option != null)
                    selectElem.removeChild(toRemove[i]);
            }
        }
        else if ((currentTarget == updateElem) ||
                 (currentTarget == insertElem))
        {
            Document doc = getItsNatDocument().getDocument();
            String newItem = itemElem.getValue();
            try
            {
                int pos = Integer.parseInt(posElem.getValue());
                if (currentTarget == updateElem)
                {
                    HTMLOptionElement option = getOptionElement(pos);
                    if (option != null)
                        ItsNatDOMUtil.setTextContent(option,newItem);
                    else
                        getItsNatDocument().addCodeToSend("alert('Bad Position');");
                }
                else
                {
                    HTMLOptionElement before = (HTMLOptionElement)getOptionElement(pos);
                    HTMLOptionElement added = (HTMLOptionElement)doc.createElement("option");
                    added.appendChild(doc.createTextNode(newItem));
                    selectElem.add(added, before);
                    selectElem.setSelectedIndex(pos);
                }
            }
            catch(NumberFormatException ex)
View Full Code Here

        if (options != null)
        {
            int i = 0;
            for(Iterator<Node> it = options.iterator(); it.hasNext(); i++)
            {
                HTMLOptionElement option = (HTMLOptionElement)it.next();
                if (option.getSelected()) return i;
            }
        }

        return -1;
    }
View Full Code Here

        return -1;
    }

    public void setSelectedIndex( int selectedIndex )
    {
        HTMLOptionElement optionSelected = null;
        LinkedList<Node> options = getOptionsArray();
        if (options != null)
        {
            int i = 0;
            for(Iterator<Node> it = options.iterator(); it.hasNext(); i++)
            {
                HTMLOptionElement option = (HTMLOptionElement)it.next();
                if (i == selectedIndex) optionSelected = option;
                else HTMLOptionElementImpl.setSelected(option, false);
            }
        }
        // Hacemos la selecci�n al final, as� evitamos que en un momento dado haya dos elementos seleccionados
View Full Code Here

    }

    public void remove( int index )
    {
        if (index < 0) return;
        HTMLOptionElement option = getOptionElement(index);
        if (option != null)
            option.getParentNode().removeChild(option);
    }
View Full Code Here

TOP

Related Classes of org.w3c.dom.html.HTMLOptionElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.