Use the richtexteditor component

Source: Internet
Author: User

A text editor, such as a blog or forum, is sometimes required in a web project. The document editor component (richtexteditor) is included in the ADF framework ), the following describes how to use the self-contained text editor of the ADF;

Usage:

For example, to create a simple post Vo, drag the VO to the form of the form displayed on the page, and change the post content attribute to display in a text editor:

<AF: richtexteditor value = "# {bindings. topiccontent. inputvalue} "<br/> includesc =" # {bindings. topiccontent. hints. tooltip} "<br/> id =" it2 "label =" content "> <br/> </AF: richtexteditor> <br/>

Run the page, enter the text in the text editor, add a style, and save the results. The results cannot be saved to the database.

 

Cause:

In Oracle databases, large objects are generally stored in blob or clob type, instead of varchar. varchar can only store 4 kb at the maximum. Therefore, the content attribute of the post in the above example is clob type, instead of the varchar type, this type causes the data to be saved to the database to fail.

 

Solution:

Add Converter

1. Added converter class:

Package view. bean. converter; </P> <p> Import javax. faces. component. uicomponent; <br/> Import javax. faces. context. facescontext; <br/> Import javax. faces. convert. converter; <br/> Import javax. faces. convert. converterexception; <br/> Import oracle. jbo. domain. clobdomain; </P> <p> public class clobconverter implements converter {<br/> Public clobconverter () {<br/>}</P> <p> Public object getasobject (facescontext context, uicomponent component, <br/> string value) {<br/> If (context = NULL | Component = NULL) {<br/> throw new nullpointerexception ("facescontext and uicomponent can not be null "); <br/>}< br/> If (value = NULL) {<br/> return NULL; <br/>}< br/> try {<br/> return New clobdomain (value); <br/>} catch (exception ex) {<br/> final string message = <br/> string. format ("unable to convert Boolean value/" % S/"into a oracle. jbo. domain. number ", <br/> value); <br/> throw new converterexception (message, ex ); <br/>}</P> <p> Public String getasstring (facescontext context, <br/> uicomponent component, <br/> object value) {<br/> If (context = NULL | Component = NULL) {<br/> throw new nullpointerexception ("facescontext and uicomponent can not be null "); <br/>}< br/> return value. tostring (); <br/>}< br/>}

 

2. configure this class in faces-config.xml files:

 <Converter> <br/> <converter-ID> clobconverter </Converter-ID> <br/> <converter-class> View. bean. converter. clobconverter </Converter-class> <br/> </Converter>

 

3. Select this type of converter for the converter attribute of the text editor component on the page:

<AF: richtexteditor value = "# {bindings. topiccontent. inputvalue} "<br/> includesc =" # {bindings. topiccontent. hints. tooltip} "<br/> id =" it2 "label =" content "converter =" clobconverter "> <br/> </AF: richtexteditor> <br/>

Run the page again, enter the text and style in the text editor, and save the settings.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.