Insert

Allows for the insertion of text (with a specified format) into the HTML response. The text itself can be filtered or not. When filtering is enabled (the default), certain characters (such as < and > ) are escaped into HTML safe representations (such as &lt; and &gt; ).

Also allows insertion of multi-line text, breaking it into individual lines according to a mode. Commonly used to properly display the data provided by a user via the TextArea component.

See also: org.apache.tapestry.components.Insert RenderBlock , RenderBody

Parameters

Name Type Required Default Value Description
value Object no The value to be inserted. If the binding is null, then nothing is inserted. Any object may be inserted, the toString() method is used to convert it to a printable value.
format Format no An optional format object used to convert the value parameter for insertion into the HTML response.
class String no If specified, then the output is wrapped in an HTML tag, using the value specified as the CSS class. (the html tag being whatever you used to reference the component to begin with )

Warning:

Using class to force tag rendering is now deprecated, please use the renderTag parameter to control tag rendering.

renderTag boolean no false If specified, then the output is wrapped in an HTML tag.

Example:

<div jwcid="@Insert" value="literal:TestValue" class="myStyle" id="An Id" renderTag="true">
Text
</div>
raw boolean no false If true, then the method IMarkupWriter.printRaw(String) is used, rather than IMarkupWriter.print(String) .

This bypasses the normal safeguards and is used when the value to insert contains HTML markup that should be emitted as is.

mode InsertMode no Controls how each line is rendered.

The OGNL expression @org.apache.tapestry.components.InsertMode@PARAGRAPH OR @org.apache.tapestry.components.InsertMode@BREAK can be used to specify paragraph or line break rendering mode.

Body: removed

Informal parameters: allowed

Reserved parameters: none

The value parameter is split into multiple lines when specifying a "mode" paramater, and each line is printed. The BREAK mode renders a <br/> tag between lines (that is, before each line after the first line output). The alternate mode renders <p> and </p> tags around each line.

Examples

Inserts the pages dueDate and applies the specified DateFormat and HTML class. Example output:

Insert Screen Shot

HTML template

<table class="examples" cellpadding="8">
<tr>
 <td>
 The order was due on the <font color="red"><b>
 <span jwcid="@Insert" value="ognl:date" format="ognl:dateFormat" class="ognl:dueClass">21 January 2002</span>. 	
 </td>
</tr>
</table>

This will extract the date and dueClass properties from the page. It will also obtain the dateFormat property (which is lazily instantiated), and use that to format the date before inserting it.

Java class

public abstract class EnquiryPage extends BasePage 
{
  private Format _dateFormat;

  public Format getDateFormat()
  {
    if (_dateFormat == null)
      _dateFormat = new SimpleDateFormat("dd MMM yyyy");
      
    return _dateFormat;
  }

  public abstract Date getDueDate();

  public abstract String getDueClass();
}