001: /* Html.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Mon Jul 25 11:39:49 2005, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2005 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: This program is distributed under GPL Version 2.0 in the hope that
016: it will be useful, but WITHOUT ANY WARRANTY.
017: }}IS_RIGHT
018: */
019: package org.zkoss.zul;
020:
021: import org.zkoss.lang.Objects;
022: import org.zkoss.zul.impl.XulElement;
023:
024: /**
025: * A comonent used to embed the browser native content (i.e., HTML tags)
026: * into the output sent to the browser.
027: * The browser native content is specified by {@link #setContent}.
028: *
029: * <p>Notice that {@link Html} generates HTML SPAN to enclose
030: * the embedded HTML tags. Thus, you can specify the style
031: * ({@link #getStyle}), tooltip {@link #getTooltip} and so on.
032: *
033: * <pre><code><html style="border: 1px solid blue"><![CDATA[
034: * <ul>
035: * <li>It is in a SPAN tag.</li>
036: * </ul>
037: *]]></html></code></pre>
038: *
039: * <p>The generated HTML tags will look like:
040: * <pre><code><SPAN id="xxx" style="border: 1px solid blue">
041: * <ul>
042: * <li>It is in a SPAN tag.</li>
043: * </ul>
044: *</SPAN></code></pre>
045: *
046: * <p>Since SPAN is used to enclosed the embedded HTML tags, so
047: * the following is incorrect.
048: *
049: * <pre><code><html><![CDATA[
050: * <table>
051: * <tr>
052: * <td> <-- Incomplete since it is inside SPAN -->
053: *]]></html>
054: *
055: *<textbox/>
056: *
057: *<html><![CDATA[
058: * </td>
059: * </tr>
060: * </table>
061: *]]></html></code></pre>
062: *
063: * <p>If you need to generate the HTML tags directly
064: * without enclosing with SPAN, you can use the Native namespace,
065: * http://www.zkoss.org/2005/zk/native.
066: * Refer to the Developer's Guide for more information.
067: *
068: * <p>A non-XUL extension.
069: *
070: * @author tomyeh
071: */
072: public class Html extends XulElement {
073: private String _content = "";
074:
075: /** Contructs a {@link Html} component to embed HTML tags.
076: */
077: public Html() {
078: }
079:
080: /** Contructs a {@link Html} component to embed HTML tags
081: * with the specified content.
082: */
083: public Html(String content) {
084: _content = content != null ? content : "";
085: }
086:
087: /** Returns the embedded content (i.e., HTML tags).
088: * <p>Default: empty ("").
089: */
090: public String getContent() {
091: return _content;
092: }
093:
094: /** Sets the embedded content (i.e., HTML tags).
095: */
096: public void setContent(String content) {
097: if (content == null)
098: content = "";
099: if (!Objects.equals(_content, content)) {
100: _content = content;
101: invalidate();
102: }
103: }
104:
105: //-- Component --//
106: /** Default: not childable.
107: */
108: public boolean isChildable() {
109: return false;
110: }
111: }
|