eu.webtoolkit.jwt
Class WPushButton

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WWebWidget
              extended by eu.webtoolkit.jwt.WInteractWidget
                  extended by eu.webtoolkit.jwt.WFormWidget
                      extended by eu.webtoolkit.jwt.WPushButton

public class WPushButton
extends WFormWidget

A widget that represents a push button.

To act on a button click, connect a slot to the WInteractWidget#clicked() signal.

WPushButton is an inline widget.

CSS

The widget corresponds to the HTML <button> tag (with some exceptions in the bootstrap theme).


Field Summary
 
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETPS_JS
 
Constructor Summary
WPushButton()
          Creates a push button.
WPushButton(java.lang.CharSequence text)
          Creates a push button with given label text.
WPushButton(java.lang.CharSequence text, WContainerWidget parent)
          Creates a push button with given label text.
WPushButton(WContainerWidget parent)
          Creates a push button.
 
Method Summary
 EventSignal checked()
          Signal emitted when the button gets checked.
 WLink getIcon()
          Returns the icon.
 WLink getLink()
          Returns the destination link.
 AnchorTarget getLinkTarget()
          Returns the location where the linked content should be displayed.
 WPopupMenu getMenu()
           
 java.lang.String getRef()
          Deprecated. Use getLink() instead.
 WResource getResource()
          Deprecated. Use getLink() instead.
 WString getText()
          Returns the button text.
 TextFormat getTextFormat()
          Returns the text format.
 java.lang.String getValueText()
          Returns the current value.
 boolean isCheckable()
          Returns whether a button is checkable.
 boolean isChecked()
          Returns the button state.
 boolean isDefault()
          Returns whether the button is a default button.
 void refresh()
          Refresh the widget.
 void remove()
          Destructor.
 void setCheckable(boolean checkable)
          Sets whether the button is checkable.
 void setChecked()
          Checks the button.
 void setChecked(boolean checked)
          Sets the button state.
 void setDefault(boolean enabled)
          Sets the default property.
 void setIcon(WLink link)
          Sets an icon.
 void setLink(WLink link)
          Sets a destination link.
 void setLinkTarget(AnchorTarget target)
          Sets the link target.
 void setMenu(WPopupMenu popupMenu)
           
 void setRef(java.lang.String url)
          Deprecated. Use setLink() insteadd.
 void setResource(WResource resource)
          Deprecated. Use setLink() instead.
 boolean setText(java.lang.CharSequence text)
          Sets the button text.
 boolean setTextFormat(TextFormat textFormat)
          Sets the text format.
 void setUnChecked()
          Unchecks the button.
 void setValueText(java.lang.String value)
          Sets the current value.
 EventSignal unChecked()
          Signal emitted when the button gets unchecked.
 
Methods inherited from class eu.webtoolkit.jwt.WFormWidget
blurred, changed, enableAjax, focussed, getEmptyText, getLabel, getTabIndex, getValidator, hasFocus, isReadOnly, propagateSetEnabled, render, selected, setEmptyText, setEnabled, setFocus, setFocus, setHidden, setReadOnly, setTabIndex, setToolTip, setValidator, validate, validated
 
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, touchEnded, touchMoved, touchStarted
 
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, callJavaScriptMember, childrenChanged, createActualElement, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, getAttributeValue, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getSelfWidget, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasStyleClass, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isVisible, jsStringLiteral, jsStringLiteral, removeScript, removeStyleClass, resize, setAttributeValue, setClearSides, setDecorationStyle, setDisabled, setFloatSide, setHiddenKeepsGeometry, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setVerticalAlignment, updateSignalConnection
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isExposed, isLayoutSizeAware, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, scheduleRender, scheduleRerender, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
 
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WPushButton

public WPushButton(WContainerWidget parent)
Creates a push button.


WPushButton

public WPushButton()
Creates a push button.

Calls this((WContainerWidget)null)


WPushButton

public WPushButton(java.lang.CharSequence text,
                   WContainerWidget parent)
Creates a push button with given label text.

The default text format is PlainText.


WPushButton

public WPushButton(java.lang.CharSequence text)
Creates a push button with given label text.

Calls this(text, (WContainerWidget)null)

Method Detail

remove

public void remove()
Description copied from class: WFormWidget
Destructor.

If a label was associated with the widget, its buddy is reset to null.

Overrides:
remove in class WFormWidget
See Also:
WContainerWidget.removeWidget(WWidget widget)

setDefault

public void setDefault(boolean enabled)
Sets the default property.

The only effect of a default button is that it is may be rendered in a different style, depending on the theme.


isDefault

public boolean isDefault()
Returns whether the button is a default button.

See Also:
setDefault(boolean enabled)

setCheckable

public void setCheckable(boolean checkable)
Sets whether the button is checkable.

A checkable button can be checked and unchecked, and clicking will toggle between these two states.

See Also:
setChecked(boolean checked)

isCheckable

public boolean isCheckable()
Returns whether a button is checkable.

See Also:
setCheckable(boolean checkable)

setChecked

public void setChecked(boolean checked)
Sets the button state.

This is ignored for a button which is not checkable.

This method does not emit one of the checked() or unChecked() signals.

See Also:
setCheckable(boolean checkable), setChecked(), setUnChecked()

setChecked

public void setChecked()
Checks the button.

Does not emit the checked() signal.

See Also:
setChecked(boolean checked)

setUnChecked

public void setUnChecked()
Unchecks the button.

Does not emit the unChecked() signal.

See Also:
setChecked(boolean checked)

isChecked

public boolean isChecked()
Returns the button state.

See Also:
setChecked()

setText

public boolean setText(java.lang.CharSequence text)
Sets the button text.

The default text format is TextFormat.PlainText.

When the current text format is TextFormat.XHTMLText, and text is literal (not created using ), it is parsed using an XML parser which discards malicious tags and attributes silently. When the parser encounters an XML parse error, the textFormat is changed to TextFormat.PlainText.

Returns whether the text could be set using the current textFormat. A return value of false indicates that the text format was changed in order to be able to accept the new text.

See Also:
setTextFormat(TextFormat textFormat)

getText

public WString getText()
Returns the button text.

See Also:
setText(CharSequence text)

setTextFormat

public boolean setTextFormat(TextFormat textFormat)
Sets the text format.

The textFormat controls how the string should be interpreted: either as plain text, which is displayed literally, or as XHTML-markup.

When changing the textFormat to TextFormat.XHTMLText, and the current text is literal (not created using ), the current text is parsed using an XML parser which discards malicious tags and attributes silently. When the parser encounters an XML parse error, the textFormat is left unchanged, and this method returns false.

Returns whether the textFormat could be set for the current text.

The default format is TextFormat.PlainText.


getTextFormat

public TextFormat getTextFormat()
Returns the text format.

See Also:
setTextFormat(TextFormat textFormat)

setIcon

public void setIcon(WLink link)
Sets an icon.

The icon is placed to the left of the text.


getIcon

public WLink getIcon()
Returns the icon.

See Also:
setIcon(WLink link)

setLink

public void setLink(WLink link)
Sets a destination link.

This method can be used to make the button behave like a WAnchor (or conversely, an anchor look like a button) and redirect to another URL when clicked.

The link may be to a URL, a resource, or an internal path.

By default, a button does not link to an URL and you should listen to the WInteractWidget#clicked() signal to react to a click event.


getLink

public WLink getLink()
Returns the destination link.

See Also:
setLink(WLink link)

setRef

public void setRef(java.lang.String url)
Deprecated. Use setLink() insteadd.

Sets a destination URL (deprecated).


getRef

public java.lang.String getRef()
Deprecated. Use getLink() instead.

Returns the destination URL (deprecated).

When the button refers to a resource, the current resource URL is returned. Otherwise, the URL is returned that was set using setRef().

See Also:
setRef(String url), WResource.getUrl()

setResource

public void setResource(WResource resource)
Deprecated. Use setLink() instead.

Sets a destination resource (deprecated).

This method can be used to make the button behave like a WAnchor (or conversely, an anchor look like a button) and redirect to another resource when clicked.

A resource specifies application-dependent content, which may be generated by your application on demand.

This sets the resource as the destination of the button, and is an alternative to setRef(). The resource may be cleared by passing resource = null.

The button does not assume ownership of the resource.

See Also:
setRef(String url)

getResource

public WResource getResource()
Deprecated. Use getLink() instead.

Returns the destination resource (deprecated).

Returns null if no resource has been set.

See Also:
setResource(WResource resource)

getValueText

public java.lang.String getValueText()
Returns the current value.

Returns an empty string, since a button has no value.

Specified by:
getValueText in class WFormWidget

setValueText

public void setValueText(java.lang.String value)
Sets the current value.

Has no effect, since a button has not value.

Specified by:
setValueText in class WFormWidget

setLinkTarget

public void setLinkTarget(AnchorTarget target)
Sets the link target.

This sets the target where the linked contents should be displayed. The default target is TargetSelf.


getLinkTarget

public AnchorTarget getLinkTarget()
Returns the location where the linked content should be displayed.

See Also:
setLinkTarget(AnchorTarget target)

setMenu

public void setMenu(WPopupMenu popupMenu)

getMenu

public WPopupMenu getMenu()

refresh

public void refresh()
Description copied from class: WWidget
Refresh the widget.

The refresh method is invoked when the locale is changed using WApplication#setLocale() or when the user hit the refresh button.

The widget must actualize its contents in response.

Overrides:
refresh in class WFormWidget

checked

public EventSignal checked()
Signal emitted when the button gets checked.

This signal is emitted when the user checks the button.

You can use the WInteractWidget#clicked() signal to react to any change of the button state.

See Also:
setCheckable(boolean checkable)

unChecked

public EventSignal unChecked()
Signal emitted when the button gets unchecked.

This signal is emitted when the user unchecks the button.

You can use the WInteractWidget#clicked() signal to react to any change of the button state.

See Also:
setCheckable(boolean checkable)