001 /*
002 * This file is part of the Echo Point Project. This project is a
003 * collection of Components that have extended the Echo Web Application
004 * Framework Version 3.
005 *
006 * Version: MPL 1.1
007 *
008 * The contents of this file are subject to the Mozilla Public License Version
009 * 1.1 (the "License"); you may not use this file except in compliance with
010 * the License. You may obtain a copy of the License at
011 * http://www.mozilla.org/MPL/
012 *
013 * Software distributed under the License is distributed on an "AS IS" basis,
014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015 * for the specific language governing rights and limitations under the
016 * License.
017 */
018
019 package echopoint;
020
021 import echopoint.internal.AbstractHtmlComponent;
022
023 /**
024 * DirectHtml is a very lightweight component that will insert HTML text
025 * directly onto the client. The inserted text is contained within a parent
026 * <code><div></code> element. This component will <b>not</b> validate
027 * this HTML text.
028 *
029 * <p>This component differs from {@link HtmlLabel} in that
030 * this compoonent is designed to hold more complex HTML content while
031 * {@link HtmlLabel} is designed to hold simple (phrase) HTML content.</p>
032 *
033 * <p><b>Note:</b> Be careful of your use of id attributes in the HTML
034 * text as they may clash with Echo3 generated ones. Also note that this
035 * component does not support child components.</p>
036 *
037 * <p>The following shows sample use of this component:</p>
038 * <pre>
039 * import nextapp.echo.app.Column;
040 * import echopoint.DirectHtml;
041 *
042 * ...
043 * final Column column = new Column();
044 * final String text = "<p>First line.</p>" +
045 * "<p>Second <b>line</b></p>" +
046 * "<p><b><i>Third</i> line</b></p>";
047 * final DirectHtml html = new DirectHtml( text );
048 * html.setStyleName( "Default.DirectHtml" );
049 * html.setTarget( "_new" );
050 * column.add( html );
051 * </pre>
052 *
053 * @author Rakesh 2008-03-22
054 * @version $Id: DirectHtml.java 5 2008-07-10 01:49:16Z sptrakesh $
055 */
056 public class DirectHtml extends AbstractHtmlComponent
057 {
058 private static final long serialVersionUID = 1l;
059
060 /** Default constructor. Create a new instance with empty text. */
061 public DirectHtml() {}
062
063 /**
064 * Create a new instance enclosing the specified HTML text.
065 *
066 * @param text The HTML text that is to be displayed in this component.
067 */
068 public DirectHtml( final String text )
069 {
070 super( text );
071 }
072
073 /**
074 * Create a new instance enclosing the specified HTML text and setting the
075 * <code>target</code> attribute for all anchor tags to the value specified.
076 *
077 * @param text The HTML text that is to be displayed in this component.
078 * @param target The target attribute. Note that target attributes that
079 * already exist in anchor tags are left untouched.
080 */
081 public DirectHtml( final String text, final String target )
082 {
083 this( text );
084 setTarget( target );
085 }
086 }