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
OptionElement
is 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>
Form
is sent to the web server, a name/value pair will be sent which uses the name of theSelectElement
and 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 newOptionElement
object with the specifiedvalue
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HtmlElement
clone()
Creates a copy of this HTML element.void
delete()
static long
getCPtr(OptionElement obj)
For internal use only.boolean
isSuccessfulControl()
Returnstrue
if thisOptionElement
currently represents a successful control.boolean
selected()
Returnstrue
if thisOptionElement
has been selected.void
setSelected(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.UnsupportedEncodingException
Creates a newOptionElement
object 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:
delete
in classHtmlElement
-
selected
public boolean selected()
Returnstrue
if thisOptionElement
has been selected. AnOptionElement
is selected if it has a"selected"
attribute, i.e. ifhasAttribute("selected")
returnstrue
.- Returns:
true
if 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
-true
to select theOptionElement
,false
to de-select it- See Also:
selected()
,isSuccessfulControl()
-
isSuccessfulControl
public boolean isSuccessfulControl()
Returnstrue
if thisOptionElement
currently 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
OptionElement
is successful if it has beenselected()
.- Overrides:
isSuccessfulControl
in classHtmlElement
- Returns:
true
if thisOptionElement
represents a successful control- See Also:
setSelected(boolean)
,selected()
-
clone
public HtmlElement clone()
Description copied from class:HtmlElement
Creates a copy of this HTML element.- Overrides:
clone
in classHtmlElement
- Returns:
- a new
HtmlElement
object which is an exact copy of this HTML element
-
-