Class WTextEdit


public class WTextEdit extends WTextArea
A rich-text XHTML editor.

The editor provides interactive editing of XHTML text. By default it provides basic mark-up (font, formatting, color, links, and lists), but additional buttons may be added to the tool bars that add additional formatting options.

The implementation is based on TinyMCE. The widget may be configured and tailored using the setConfigurationSetting() and related methods that provide direct access to the underlying TinyMCE component.

You can use this widget with TinyMCE version 3 or version 4.

The choice is global and set using Configuration#setTinyMCEVersion(int).

CSS

Styling through CSS is not applicable.

Default configuration of a WTextEdit

  • Constructor Details

  • Method Details

    • remove

      public void remove()
      Destructor.
      Overrides:
      remove in class WFormWidget
      See Also:
    • getVersion

      public int getVersion()
      Returns the TinyMCE version.

      This returns the configured version of TinyMCE (currently 3 or 4).

    • setText

      public void setText(String text)
      Sets the content.

      The text should be valid XHTML.

      The default value is "".

      Overrides:
      setText in class WTextArea
    • setStyleSheet

      public void setStyleSheet(String uri)
      Sets the stylesheet for displaying the content.

      The content is rendered using the rules defined in this stylesheet. The stylesheet is also used to derive additional styles that are available in the text editor, for example in the "styleselect" button.

      Multiple stylesheets may be specified as a comma separated list.

    • getStyleSheet

      public String getStyleSheet()
      Returns the content stylesheet.

      See Also:
    • setExtraPlugins

      public void setExtraPlugins(String plugins)
      Loads additional TinyMCE plugins.

      Wt loads by default only the plugin 'safari' (which adds support for the Safari web browser). Use this method to load additional plugins. Multiple plugins may be specified as a comma separated list.

      The various plugins are described in the TinyMCE documentation.

      Note: Plugins can only be loaded before the initial display of the widget.

    • getExtraPlugins

      public String getExtraPlugins()
      Returns the extra plugins.

      See Also:
    • setToolBar

      public void setToolBar(int i, String config)
      Configures a tool bar.

      This configures the buttons for the i'th tool bar (with 0 <= i <= 3).

      TinyMCE 3

      The syntax and available buttons is documented in the TinyMCE documentation.

      The default config for the first tool bar (i = 0) is: "fontselect, |, bold, italic, underline, |, fontsizeselect, |, forecolor, backcolor, |, justifyleft, justifycenter, justifyright, justifyfull, |, anchor, |, numlist, bullist".

      By default, the other three tool bars are disabled (config = "").

      TinyMCE 4

      The syntax and available buttons is documented in the TinyMCEdocumentation.

      The default config for the first tool bar (i = 0) is: "undo redo | styleselect | bold italic | link".

      Some buttons are only available after loading extra plugins using setExtraPlugins().

      Note: The tool bar configuration can only be set before the initial display of the widget.

    • getToolBar

      public String getToolBar(int i)
      Returns a tool bar configuration.

      See Also:
    • setConfigurationSetting

      public void setConfigurationSetting(String name, Object value)
      Configure a TinyMCE setting.

      A list of possible settings can be found at: http://tinymce.moxiecode.com/wiki.php/Configuration

      The widget itself will also define a number of configuration settings and these may be overridden using this method.

    • getConfigurationSetting

      public Object getConfigurationSetting(String name)
      Returns a TinyMCE configuration setting's value.

      An empty Any is returned when no value could be found for the provided argument.

    • setPlaceholderText

      public void setPlaceholderText(CharSequence placeholder)
      Sets the placeholder text.

      This method is not supported on WTextEdit and will thrown an exception instead.

      Overrides:
      setPlaceholderText in class WFormWidget
    • setReadOnly

      public void setReadOnly(boolean readOnly)
      Description copied from class: WFormWidget
      Sets the element read-only.

      A read-only form element cannot be edited, but the contents can still be selected.

      By default, a form element area is not read-only.

      Overrides:
      setReadOnly in class WFormWidget
      See Also:
    • propagateSetEnabled

      public void propagateSetEnabled(boolean enabled)
      Description copied from class: WWidget
      Propagates that a widget was enabled or disabled through children.

      When enabling or disabling a widget, you usually also want to disable contained children. This method is called by setDisabled() to propagate its state to all children.

      You may want to reimplement this method if they wish to render differently when a widget is disabled. The default implementation will propagate the signal to all children.

      Overrides:
      propagateSetEnabled in class WFormWidget
    • resize

      public void resize(WLength width, WLength height)
      Description copied from class: WWidget
      Resizes the widget.

      Specifies a fixed size for this widget, setting CSS width and height properties. By default a widget has automatic width and height, which sets a size for the widget following CSS rules.

      When the widget is not managed by a layout manager, the automatic (natural) size of a widget depends on whether they widget is a block or inline widget:

      • a block widget takes by default the width of the parent, and the height that it needs based on its contents
      • an inline widget takes the width and height that it needs based on its contents (possibly wrapping over multiple lines). The width and height of an inline widget cannot be changed (by the letter of CSS, although most browsers will react to it in varying ways).

      When inserted in a layout manager, the size set will be used as a widget's preferred size, but the widget may be given a different size by the layout manager based on available space and stretch factors. The actual size given by a layout manager may be retrieved by making the widget "layout size aware", using setLayoutSizeAware(). If you have defined a "wtResize()" JavaScript method for the widget, then this method will also be called.

      The default width and height of a widget is WLength.Auto.

      Overrides:
      resize in class WWebWidget
      See Also:
    • rendered

      public JSignal rendered()
      Signal emitted when rendered.

      A text edit is instantiated asynchronously as it depends on additional JavaScript libraries and initialization. This signal is emitted when the component is initialized. The underlying TinyMCE editor component is accessible as WWidget.getJsRef() + ".ed".

    • getDomChanges

      protected void getDomChanges(List<DomElement> result, WApplication app)
      Description copied from class: WWebWidget
      Get DOM changes for this widget.

      This is an internal function, and should not be called directly, or be overridden!

      Overrides:
      getDomChanges in class WWebWidget
    • boxPadding

      protected int boxPadding(Orientation orientation)
      Description copied from class: WWidget
      Returns the widget's built-in padding.

      This is used by the layout managers to correct for a built-in padding which interferes with setting a widget's width (or height) to 100%.

      A layout manager needs to set the width to 100% only for form widgets (WTextArea, WLineEdit, WComboBox, etc...). Therefore, only for those widgets this needs to return the padding (the default implementation returns 0).

      For form widgets, the padding depends on the specific browser/platform combination, unless an explicit padding is set for the widget.

      When setting an explicit padding for the widget using a style class, you will want to reimplement this method to return this padding in case you want to set the widget inside a layout manager.

      Overrides:
      boxPadding in class WTextArea
      See Also:
    • boxBorder

      protected int boxBorder(Orientation orientation)
      Description copied from class: WWidget
      Returns the widget's built-in border width.

      This is used by the layout managers to correct for a built-in border which interferes with setting a widget's width (or height) to 100%.

      A layout manager needs to set the width to 100% only for form widgets (WTextArea, WLineEdit, WComboBox, etc...). Therefore, only for those widgets this needs to return the border width (the default implementation returns 0).

      For form widgets, the border width depends on the specific browser/platform combination, unless an explicit border is set for the widget.

      When setting an explicit border for the widget using a style class, you will want to reimplement this method to return this border width, in case you want to set the widget inside a layout manager.

      Overrides:
      boxBorder in class WTextArea
      See Also: