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.