Package com.facilita.fc.web
Class OptionElement
- java.lang.Object
-
- com.facilita.fc.web.HtmlElement
-
- com.facilita.fc.web.OptionElement
-
public class OptionElement extends HtmlElement
Represents an HTML option element within an HTML form. An HTML element is everything from the start tag to the end tag.An
OptionElementis used to define an available option in a drop-down list represented by aSelectElement.e.g.
When the containing<select name="drink"> <option value="lemonade">Lemonade</option> <option value="coke">Coke</option> <option value="pepsi">Pepsi</option> <option value="tango">Tango</option> </select>Formis sent to the web server, a name/value pair will be sent which uses the name of theSelectElementand the value of the currently selectedOptionElement.
-
-
Constructor Summary
Constructors Constructor Description OptionElement(long cPtr, boolean cMemoryOwn)For internal use only.OptionElement(java.lang.String value)Creates a newOptionElementobject with the specifiedvalue.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HtmlElementclone()Creates a copy of this HTML element.voiddelete()static longgetCPtr(OptionElement obj)For internal use only.booleanisSuccessfulControl()Returnstrueif thisOptionElementcurrently represents a successful control.booleanselected()Returnstrueif thisOptionElementhas been selected.voidsetSelected(boolean selected)Sets or removes the"selected"attribute for thisOptionElement.-
Methods inherited from class com.facilita.fc.web.HtmlElement
getAfterEndTagPosition, getAfterStartTagPosition, getAttribute, getAttributes, getCharEncoding, getContent, getContentPosition, getCPtr, getId, getName, getTag, getValue, hasAttribute, isDisabled, removeAttribute, setAttribute, setAttribute, setCharEncoding, setContent, setDisabled, setId, setName, setValue
-
-
-
-
Constructor Detail
-
OptionElement
public OptionElement(long cPtr, boolean cMemoryOwn)For internal use only. Of no interest to the user.- Parameters:
cPtr- pointer to the CPP wrapped objectcMemoryOwn- indicates if this object is responsible for memory management of the CPP object
-
OptionElement
public OptionElement(java.lang.String value) throws java.io.UnsupportedEncodingExceptionCreates a newOptionElementobject with the specifiedvalue.- Parameters:
value- the value of the option- Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
-
Method Detail
-
getCPtr
public static long getCPtr(OptionElement obj)
For internal use only. Of no interest to the user.- Parameters:
obj- a reference to an object of this class- Returns:
- a long containing the address of the CPP wrapped object
-
delete
public void delete()
- Overrides:
deletein classHtmlElement
-
selected
public boolean selected()
Returnstrueif thisOptionElementhas been selected. AnOptionElementis selected if it has a"selected"attribute, i.e. ifhasAttribute("selected")returnstrue.- Returns:
trueif this option has been selected- See Also:
setSelected(boolean)
-
setSelected
public void setSelected(boolean selected)
Sets or removes the"selected"attribute for thisOptionElement.setSelected(true)is equivalent tosetAttribute("selected").setSelected(false)is equivalent toremoveAttribute("selected").- Parameters:
selected-trueto select theOptionElement,falseto de-select it- See Also:
selected(),isSuccessfulControl()
-
isSuccessfulControl
public boolean isSuccessfulControl()
Returnstrueif thisOptionElementcurrently represents a successful control. A successful control is one that is valid for submission, i.e. one that will be sent to the web server when the form is submitted.An
OptionElementis successful if it has beenselected().- Overrides:
isSuccessfulControlin classHtmlElement- Returns:
trueif thisOptionElementrepresents a successful control- See Also:
setSelected(boolean),selected()
-
clone
public HtmlElement clone()
Description copied from class:HtmlElementCreates a copy of this HTML element.- Overrides:
clonein classHtmlElement- Returns:
- a new
HtmlElementobject which is an exact copy of this HTML element
-
-