Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlOption


     * Adds a new item to the list (optionally) before the specified item in Mozilla way.
     * @param newOptionObject the DomNode to insert
     * @param beforeOptionObject the DomNode to insert the previous element before (null if at end)
     */
    protected void add(final HTMLOptionElement newOptionObject, final Object beforeOptionObject) {
        final HtmlOption beforeOption;
        if (beforeOptionObject == null) {
            beforeOption = null;
        }
        else if (Context.getUndefinedValue().equals(beforeOptionObject)) {
            throw Context.reportRuntimeError("Not enough arguments [SelectElement.add]");
View Full Code Here


     * @param beforeOption the option that should be after the option to add
     */
    protected void addBefore(final HTMLOptionElement newOptionObject, final HtmlOption beforeOption) {
        final HtmlSelect select = getHtmlSelect();

        HtmlOption htmlOption = newOptionObject.getDomNodeOrNull();
        if (htmlOption == null) {
            htmlOption = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement(
                    select.getPage(), HtmlOption.TAG_NAME, null);
        }

View Full Code Here

        }

        final List<HtmlOption> allOptions = htmlSelect.getOptions();

        if (index < allOptions.size()) {
            final HtmlOption itemToSelect = allOptions.get(index);
            htmlSelect.setSelectedAttribute(itemToSelect, true, false);
        }
    }
View Full Code Here

        if (defaultSelected) {
            attributes = new AttributesImpl();
            attributes.addAttribute(null, "selected", "selected", null, "selected");
        }

        final HtmlOption htmlOption = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement(
                page, HtmlOption.TAG_NAME, attributes);
        htmlOption.setSelected(selected);
        setDomNode(htmlOption);

        if (newText != null && !newText.equals("undefined")) {
            htmlOption.appendChild(new DomText(page, newText));
        }
        if (newValue != null && !newValue.equals("undefined")) {
            htmlOption.setValueAttribute(newValue);
        }
    }
View Full Code Here

            // Remove the indexed option.
            htmlSelect_.removeOption(index);
        }
        else {
            final HTMLOptionElement option = (HTMLOptionElement) newValue;
            final HtmlOption htmlOption = option.getDomNodeOrNull();
            if (index >= jsxGet_length()) {
                // Add a new option at the end.
                htmlSelect_.appendOption(htmlOption);
            }
            else {
View Full Code Here

        if (currentLength > newLength) {
            htmlSelect_.setOptionSize(newLength);
        }
        else {
            for (int i = currentLength; i < newLength; i++) {
                final HtmlOption option = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement(
                        htmlSelect_.getPage(), HtmlOption.TAG_NAME, null);
                htmlSelect_.appendOption(option);
                if (!getBrowserVersion().isIE()) {
                    option.appendChild(new DomText(option.getPage(), ""));
                }
            }
        }
    }
View Full Code Here

        HtmlSelect adhocList = (HtmlSelect)adhocForm.getHtmlElementById("sqlQuery");
        List adhocListOptions = adhocList.getOptions();//.asText();
        //System.out.println(" adhocListOptionsText-->\n" + adhocListOptions.toString());
        String allOptionsText = "";
        for(int i=0; i<adhocListOptions.size(); i++){
          HtmlOption curOption = (HtmlOption)adhocListOptions.get(i);
          String curOptionText = curOption.getValueAttribute();
          allOptionsText = allOptionsText + curOptionText;
          if(curOptionText.equals("SELECT * FROM COMPANY")){
            adhocList.setSelectedAttribute(curOption, true);
            //System.out.println("select option..."+curOptionText);
          }
View Full Code Here

        HtmlSelect commandList = (HtmlSelect)commandForm.getHtmlElementById("DasCommand");
        List commandListOptions = commandList.getOptions();
        //System.out.println(" commandListOptionsText-->\n" + commandListOptions.toString());
        String allOptionsText = "";
        for(int i=0; i<commandListOptions.size(); i++){
          HtmlOption curOption = (HtmlOption)commandListOptions.get(i);
          String curOptionText = curOption.getValueAttribute();
          allOptionsText = allOptionsText + curOptionText;
          if(curOptionText.equals("AllCompaniesAndDepartments")){
            commandList.setSelectedAttribute(curOption, true);
            //System.out.println("select option..."+curOptionText);
          }
View Full Code Here

        HtmlSelect adhocList = (HtmlSelect)adhocForm.getHtmlElementById("sqlQuery");
        List adhocListOptions = adhocList.getOptions();//.asText();
        //System.out.println(" adhocListOptionsText-->\n" + adhocListOptions.toString());
        String allOptionsText = "";
        for(int i=0; i<adhocListOptions.size(); i++){
          HtmlOption curOption = (HtmlOption)adhocListOptions.get(i);
          String curOptionText = curOption.getValueAttribute();
          allOptionsText = allOptionsText + curOptionText;
          if(curOptionText.startsWith("{INSERT INTO DEPARTMENT (NAME, COMPANYID) VALUES ('MyDept',1)}" )){
            adhocList.setSelectedAttribute(curOption, true);
            //System.out.println("insert option..."+curOptionText);
          }
View Full Code Here

        HtmlSelect commandList = (HtmlSelect)commandForm.getHtmlElementById("DasCommand");
        List commandListOptions = commandList.getOptions();
        //System.out.println(" commandListOptionsText-->\n" + commandListOptions.toString());
        String allOptionsText = "";
        for(int i=0; i<commandListOptions.size(); i++){
          HtmlOption curOption = (HtmlOption)commandListOptions.get(i);
          String curOptionText = curOption.getValueAttribute();
          allOptionsText = allOptionsText + curOptionText;
          if(curOptionText.equals("DeleteDepartmentFromFirstCompany")){
            commandList.setSelectedAttribute(curOption, true);
            //System.out.println("delete option..."+curOptionText);
          }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.html.HtmlOption

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.