HtmlUnitSetCheckBoxTag.java from Jameleon at Krugle
Show HtmlUnitSetCheckBoxTag.java syntax highlighted
/*
Jameleon HtmlUnit plug-in - A plug-in that uses HtmlUnit to drive web sites
Copyright (C) 2006 Christian W. Hargraves (engrean@hotmail.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111AssertLevel.NO_FUNCTION07 USA
*/
package net.sf.jameleon.plugin.htmlunit.tags;
import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
/**
* This tag is used to set or unset checkboxes defined by a given XPath expression.
*
* <p>
* To use XPath to check a checkbox named <b>cb_1</b> that exists in a form with the name <b>testform</b>:<br/>
* <pre><source>
* <htmlunit-set-checkbox
* functionId="Check the checkbox named cb_1 field"
* xpath="//form[@name='testform']/input[@name='cb_1']"
* checked="true"/>
* </source></pre>
* </p>
* <p>
* To use XPath to uncheck a checkbox named <b>cb_1</b> that exists in a form with the name <b>testform</b>:
* <pre><source>
* <htmlunit-set-checkbox
* functionId="Uncheck the checkbox named cb_1 field"
* xpath="//form[@name='testform']/input[@name='cb_1']"
* checked="false"/>
* </source></pre>
* </p>
* <p>
* To use the form and the field name to check a checkbox named <b>cb_1</b> that exists in a form with the name <b>testform</b>:
* <pre><source>
* <htmlunit-set-checkbox
* functionId="Check the checkbox named cb_1 field"
* form="testform"
* fieldName="cb_1"
* checked="true"/>
* </source></pre>
* </p>
* @jameleon.function name="htmlunit-set-checkbox" type="action"
*/
public class HtmlUnitSetCheckBoxTag extends AbstractHtmlUnitCheckFieldTag{
protected void checkFieldWithValue(String fieldName, String value, boolean check){
setCheckBox(fieldName, value, check);
}
protected void checkField(HtmlInput inputField, boolean check){
((HtmlCheckBoxInput)inputField).setChecked(check);
}
protected void checkFieldWithNoValue(String fieldName, boolean check){
setCheckBox(fieldName, checked.booleanValue());
}
protected String getInputType(){
return "checkbox";
}
}
See more files for this project here