Package org.zkoss.zul

Class Html

All Implemented Interfaces:
Serializable, Cloneable, Component, Scope, ComponentCtrl

public class Html extends XulElement
A component used to embed the browser native content (i.e., HTML tags) into the output sent to the browser. The browser native content is specified by setContent(java.lang.String).

Notice that Html generates HTML SPAN to enclose the embedded HTML tags. Thus, you can specify the style (HtmlBasedComponent.getStyle()), tooltip XulElement.getTooltip() and so on.

<html style="border: 1px solid blue"><![CDATA[
 <ul>
  <li>It is in a SPAN tag.</li>
 </ul>
]]></html>

The generated HTML tags will look like:

<SPAN id="xxx" style="border: 1px solid blue">
 <ul>
  <li>It is in a SPAN tag.</li>
 </ul>
</SPAN>

Since SPAN is used to enclosed the embedded HTML tags, so the following is incorrect.

<html><![CDATA[
 <table>
  <tr>
   <td> <-- Incomplete since it is inside SPAN -->
]]></html>

<textbox/>

<html><![CDATA[
   </td>
  </tr>
 </table>
]]></html>

If you need to generate the HTML tags directly without enclosing with SPAN, you can use the Native namespace, http://www.zkoss.org/2005/zk/native. Refer to ZK Developer's Reference for more information.

A non-XUL extension.

Author:
tomyeh
See Also:
  • Constructor Details

    • Html

      public Html()
      Constructs a Html component to embed HTML tags.
    • Html

      public Html(String content)
      Constructs a Html component to embed HTML tags with the specified content.
  • Method Details

    • getContent

      public String getContent()
      Returns the embedded content (i.e., HTML tags).
    • setContent

      public void setContent(String content)
      Sets the embedded content (i.e., HTML tags).

      Default: empty ("").

      Deriving class can override it to return whatever it wants other than null.

      Security Note

      Unlike other methods, the content assigned to this method is generated directly to the browser without escaping. Thus, it is better not to have something input by the user to avoid any XSS attach.

    • renderProperties

      protected void renderProperties(ContentRenderer renderer) throws IOException
      Description copied from class: HtmlBasedComponent
      Renders the content of this component, excluding the enclosing tags and children.

      See also ZK Client-side Reference: Property Rendering

      Overrides:
      renderProperties in class XulElement
      Throws:
      IOException
    • isChildable

      protected boolean isChildable()
      Default: not childable.
      Overrides:
      isChildable in class AbstractComponent