### Create new RichFaces Documentation Jira issue

Summary
255 characters left
Description
Environment
This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.org Community Documentation

- Prev
- Next

## 6.65. < rich:insert >

### 6.65.1. Description

The <rich:insert> component is used for highlighting, source code inserting and, optionally, format the file from the application context into the page.

### 6.65.2. Key Features

- Source code highlighting

- Variety of formats for source code highlighting

Table 6.330. rich : insert attributes

Attribute Name | Description
--- | ---
binding | The attribute takes a value-binding expression for a component property of a backing bean
content | Defines the String, inserted with this component. This attribute is alternative to "src" attribute.
encoding | Attribute defines encoding for inserted content
errorContent | Attribute defines the alternative content that will be shown in case component cannot read the resource defined with 'src' attribute. If "errorContent" attribute is not defined, the component shown the actual error message in the place where the content is expected
highlight | Defines a type of code
id | Every component may have a unique id that is automatically created if omitted
rendered | If "false", this component is not rendered
src | Defines the path to the file with source code

Table 6.331. Component identification parameters

Name | Value
--- | ---
component-type | org.richfaces.ui.Insert
component-class | org.richfaces.ui.component.html.HtmlInsert
component-family | org.richfaces.ui.Insert
renderer-type | org.richfaces.ui.InsertRenderer
tag-class | org.richfaces.ui.taglib.InsertTag

### 6.65.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

Example:

    ...

          <rich:insert  src="/pages/sourcePage.xhtml" highlight="xhtml"/>

    ...

### 6.65.4. Creating the Component Dynamically Using Java

Example:

    import org.richfaces.ui.component.html.HtmlInsert;

    ...

    HtmlInsert myInsert = new HtmlInsert();

    ...

### 6.65.5. Details of Usage

The are two basic attributes. The "src" attribute defines the path to the file with source code. The "highlight" attribute defines the type of a syntax highlighting.

If "highlight" attribute is defined and JHighlight open source library is in the classpath, the text from the file is formated and colorized.

An example is placed below.

Example:

    ...

          <rich:insert  src="/pages/sourcePage.xhtml" highlight="xhtml"/>

    ...

The result of using <rich:insert> component is shown on the picture:

Figure 6.183. Source code highlighting

The <rich:insert> component provides the same functionality as JHighlight. Thus, all names of highlight style classes for source code of particular language could be changed to your names, which are used by the JHighlight library.

### 6.65.6. Look-and-Feel Customization

<rich:insert> has no skin parameters and custom style classes, as the component doesn't have own visual representation.

### 6.65.7. Relevant Resources Links

On RichFaces LiveDemo page you can found some additional information for <rich:insert> component usage.

- Prev6.64. < rich:inputNumberSpinner >
- Top of page
- Front page
- Next6.66. < rich:jQuery >