01: /* Inline.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Thu Jul 19 18:05:01 2007, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.jsf.zul.impl;
20:
21: import java.io.Writer;
22: import java.io.IOException;
23:
24: import org.zkoss.zk.ui.AbstractComponent;
25:
26: /**
27: * A component used to embed the browser native content (i.e., HTML tags)
28: * into the output sent to the browser without additional HTML SPAN.
29: * The browser native content is specified by {@link #setContent}.
30: *
31: * <p>Since the content is sent to client directly, {@link Inline}
32: * has some limitations:
33: *
34: * <ol>
35: * <li>The content cannot be changed dynamically. In other words,
36: * once the output of {@link Inline} is sent to the client,
37: * calling {@link #setContent} won't cause the client to change
38: * the content accordingly.
39: * Rather, you have to invalidate its parent, such that the new
40: * content will be sent to the client with its parent's content.</li>
41: * <li>No style, no tooltip or others to control the look of {@link Inline}.</li>
42: * </ol>
43: *
44: * @author tomyeh
45: * @see org.zkoss.zul.Html
46: */
47: public class Inline extends AbstractComponent {
48: private String _content = "";
49:
50: /** Constructs a {@link Inline} component to embed HTML tags.
51: */
52: public Inline() {
53: }
54:
55: /** Constructs a {@link Inline} component to embed HTML tags
56: * with the specified content.
57: */
58: public Inline(String content) {
59: _content = content != null ? content : "";
60: }
61:
62: /** Returns the embedded content (i.e., HTML tags).
63: * <p>Default: empty ("").
64: */
65: public String getContent() {
66: return _content;
67: }
68:
69: /** Sets the embedded content (i.e., HTML tags).
70: *
71: * <p>Note: Unlike {@link org.zkoss.zul.Html}, the content of {@link Inline}
72: * cannot be changed dynamically.
73: * In other words, once the output of
74: * {@link Inline} is sent the client, calling this method
75: * won't change the content at the client accordingly.
76: * Rather, you have to invalidate its parent, such that the new
77: * content will be sent to the client with its parent's content.
78: */
79: public void setContent(String content) {
80: _content = content != null ? content : "";
81: }
82:
83: //-- Component --//
84: /** Default: not childable.
85: */
86: public boolean isChildable() {
87: return false;
88: }
89:
90: public void redraw(Writer out) throws IOException {
91: out.write(_content); //no encodding
92: }
93: }
|