156
PrimeFaces Editor
PrimeFaces provides <p:editor> component which is used to create an editor in JSF application. We can use this editor to get user input in large amount. This editor provides editing and formating tools that we can use to format our input. We can also use it to send formated email. It includes rich attributes that are tabled below.
Editor Attributes
Attribute | Default value | Return type | Description |
---|---|---|---|
id | null | String | It is an unique identifier of the component. |
rendered | true | Boolean | It is used to specify the rendering of the component. |
value | null | Object | It is used to set value of the component. |
required | null | Boolean | It is used to mark component as required. |
validator | null | Method Expr | It is a method expression that refers to a method validationg the input. |
height | null | Integer | It is used to set height of the editor. |
width | null | Integer | It is used to set widthit of the editor. |
disabled | false | Boolean | It is used to disable editor. |
style | null | String | It is used to set inline CSS of the editor container. |
onchange | null | String | It is used to execute script when editor data changes. |
maxlength | null | Integer | It is used to set maximum length of the raw input. |
Ajax Behavior Events
SelectCeckboxMenu provides an Ajax event in addition to common dom events like change, selectCheckboxMenu.
Style Class | Applies |
---|---|
.ui-editor | It is used for main container. |
.ui-editor-toolbar | It applies on toolbar of editor. |
.ui-editor-group | It applies on button groups. |
.ui-editor-button | It is used for Each button. |
.ui-editor-divider | It is used for divider to separate buttons. |
.ui-editor-disabled | It is used to disable editor controls. |
.ui-editor-list | It applies on dropdown lists. |
.ui-editor-color | It applies on color picker. |
Example
Here, in the following example, we are implementing <p:editor> component. This example contains the following files.
JSF File
// editor.xhtml
ManagedBean
// Editor.java
Output:
Next TopicPrimeFaces InputText