General tips for integration of the Java HTML Editor in Oracle Forms

Keep in mind that the mapping of String objects in Oracle Forms is to Varchar2 - it does not allow transfers with java beans greater than 4096 chars. That's why we have provided to our Oracle customers the following methods as a workaround in order to retrieve or set the content in smaller chunks. You may use this approach for handling of content with unlimited length and adapt the following java code for use in OracleForms as demonstrated with the examples for invoking methods in the other sections of this tutorial.

Insert operations

public void openContentBuffer()

public void appendContentToContentBuffer(String content)

public void closeBufferAndInsert()

Retrieve operations

public int getBodyContentLenght() or public int getBodyContentLength() for bodyContent only

public int getContentLenght() or public int getContentLength() for entire content

public String getBodyContentPortion(int offset, int length) for bodyContent only

public String getContentPortion(int offset, int length) for entire content



Sample code:

Here we insert some content:
--------------------------------------
htmlEditor.openContentBuffer();
htmlEditor.appendContentToContentBuffer("This is ");
htmlEditor.appendContentToContentBuffer("some sample content");
htmlEditor.appendContentToContentBuffer(" long enough to be tested...");


Close the buffer and insert it in the editor
--------------------------------------
htmlEditor.closeBufferAndInsert();


Retrieve the content in small pieces
---------------------------------------
int length=htmlEditor.getBodyContentLenght();
int portionLength=5;
int i=0;
while(i+portionLength<length)
{
System.out.println( htmlEditor.getBodyContentPortion(i, portionLength<length-i?portionLength:length-i));
i=i+portionLength;
}
 

There is also this method for easier creation of custom buttons and items outside the editor and its integration into existing Oracle Forms applications:

public void executeHTMLEditorActionCommand(String actionCommand) - this allows to simulate button clicks and this way can be used to create your own buttons in the host application as they were editor's toolbar buttons. Here below is the list with commands which can be used:
 

in Oracle Forms to be used like this:

BEGIN
   CLEAR_CURRENT_DOCUMENT;
   hArgs := FBEAN.CREATE_ARGLIST;
   FBEAN.ADD_ARG(hArgs,'file-save');
END   fbean.Invoke(bean,1,'executeHTMLEditorActionCommand',hArgs);

This example will show the Save file dialog for saving the current content of the editor. Here below is the full list of commands which can be used:

"increase-indent" - increases the indent of the paragraph at the caret position
"decrease-indent" - decreases the indent of the paragraph at the caret position
"picture-properties" - shows the picture properties dialog box which allows change of the picture parameters at the caret position or does nothing if there is no picture.
"imagebutton-properties" - shows the image button form field properties dialog box which allows change of its parameters or does nothing if there is no image button.
"page-properties" - shows the page properties dialog box which allows change of the page parameters such as title, background etc.
"table-select" - selects the table at the caret position or does nothing if there is no table.
"table-row-select" - selects the table row at the caret position or does nothing if there is no table.
"design-table" - shows the design table popup of the toolbar.
"table-insert-row" - inserts new table row in the table at the caret position or does nothing if there is no table
"table-insert-column" - inserts new table column in the table at the caret position or does nothing if there is no table
"table-insert" - shows the insert table dialog which allows the selection of the number of rows and columns and inserts new table
"start-spellchecker" - starts the spellchecker and begins the check of the document.
"selectall-action" - selects the entire document.
"find-action" - shows the find/search dialog.
"replace-action" - shows the find/replace dialog.
"table-properties" - shows the table properties dialog which allows the customization of the table at the caret position or does nothing if there is no table
"cell-properties" - shows the table cell properties dialog which allows the customization of the selected table cells or does nothing if there is no table cells selected
"table-cell-merge" - merges the selected table cells and.
"table-cell-split" - splits the cell at the caret position into two cells horizontally.
"hyperlink-properties" - shows the hyperlink properties dialog and modifies or inserts new hyperlink on the selected text
"form-properties" - shows the form properties dialog for the form at the caret position or does nothing if there is no form.
"button-properties" - shows the button form field properties dialog for the form at the caret position or does nothing if there is no button form field.
"radiobutton-properties" - shows the radio button form field properties dialog for the form at the caret position or does nothing if there is no radio button form field.
"checkbox-properties" - shows the checkbox form field properties dialog for the form at the caret position or does nothing if there is no checkbox form field.
"textfield-properties" - shows the textfield form field properties dialog for the form at the caret position or does nothing if there is no textfield form field.
"textarea-properties" - shows the textarea form field properties dialog for the form at the caret position or does nothing if there is no textarea form field.
"selectfield-properties" - shows the select (dropdown menu or list) form field properties dialog for the form at the caret position or does nothing if there is no select (dropdown menu or list) form field.
"font-foreground" - sets the selected text's font foreground color visualizing the ColorChooser
"font-family" - sets the selected text's font family from the combobox on the toolbar
"font-size" - sets the font size
"insert-textfield" - inserts new textfield form field. If there is no form at the current caret position, creates new one.
"insert-textarea" - inserts new textarea form field. If there is no form at the current caret position, creates new one.
"insert-checkbox" - inserts new checkbox form field. If there is no form at the current caret position, creates new one.
"insert-radiobutton" - inserts new radiobutton form field. If there is no form at the current caret position, creates new one.
"insert-pushbutton" - inserts new pushbutton form field. If there is no form at the current caret position, creates new one.
"insert-select" - inserts new select (dropdown menu/list) form field. If there is no form at the current caret position, creates new one.
"insert-imagebutton" - inserts new imagebutton form field visualizing the file dialog to select the image URL. If there is no form at the current caret position, creates new one.
"insert-hr" - inserts new horizontal line <hr> at the caret position.
"insert-br" - inserts line break at the caret position.
"insert-p" - inserts new paragraph at the caret position.
"insert-space" - inserts white space at the caret position.
"insert-image" - inserts new image at the caret position, visualizing the file dialog.
"font-properties" - shows the font properties dialog.
"file-print" - shows the print dialog and prints out the current page.
"file-save" - saves the current page, visualizing the file dialog.
"file-open" - opens a new file showing the file dialog.
"location-open" - opens a new file (URL) showing open location dialog.
"file-new" - creates new empty file.
"file-exit" - exits from the editor, using System.exit() asking to save the changes
"help-about" - exits from the editor, using System.exit() asking to save the changes
"copy-action" - performs copy formatted text action and copies the selection as formatted paragraphs, ready to be pasted into tables.
"paste-action" - performs paste formatted text action.
"new-editor-window" - creates new editor frame
"text-uppercase" - convert text to uppercase
"text-lowercase" - convert text to lowercase
"text-titlecase" - convert text to title case
"text-sentencecase"  - convert text to sentence case
"increase-font"  - increase font size
"decrease-font" - descrease font size
"add-word-to-dictionary" - adds word to the custom dictionary
"edit-hotspot" - modifies image map hotspot
"image-map-rect" - inserts restangle image map hotspot
"image-map-circle" - inserts circle image map hotspot
"image-map-poly" - inserts polygon image map hotspot
"pdfexport" - exports document as PDF through the PDFExport plug-in
"zoomin-text" -increases the zoom of the page
"zoomout-text" - decreases the zoom of the page
"insert-equation" - inserts equation through the equation editor plug-in
"edit-equation" - edits equation through the equation editor plug-in
"strikethrough" - strikethough the selected text
"font-underline" - underline  the selected text
"subscript" - converts text to subscript
"superscript" - converts text to superscript
"preview-go-backward" - go back on the preview pane
"preview-go-forward" - go forward on the preview pane
"show-paragraphs" - shows the paragraphs inside the document
"file-save-docx" - saves the content of the editor as MS Word Docx file.
"file-save-mail"- saves the content of the editor as standard e-mail format and creates .eml file which can be opened in MS Outlook, Thunderbird etc.

You can customize the editor's appearance also by using the various properties - you can see detailed examples here below:

To set various properties like singleParagraphSpacing, flowToolbarLayout or restrictedFontList, defaultInitialFont, defaultInitialFontSize see the example:

Declare
vString1 varchar2(32000);
Begin
FBean.Set_Property('HTMLEDITOR_AREA',1,'singleParagraphSpacing','true');
FBean.set_property('HTMLEDITOR_AREA',1,'flowToolbarLayout','true');
FBean.set_property('HTMLEDITOR_AREA',1,'restrictedFontList','Arial,Verdana');
FBean.set_property('HTMLEDITOR_AREA',1,'defaultInitialFont','Arial');
FBean.set_property('HTMLEDITOR_AREA',1,'defaultInitialFontSize','10');
End;


To set the focus outside the editor

Declare

Begin
FBean.Set_Property( 'HTMLEDITOR_AREA', 1, 'transferFocusOutside', 'true');
End;




To set the focus inside the editor

Declare

Begin
FBean.Set_Property( 'HTMLEDITOR_AREA', 1, 'transferFocusInside', 'true');
End;



To disable the editor you can use the following property:

Declare
Begin

FBean.set_property('HTMLEDITOR_AREA',1,'enabled','false');

End;

To enable the editor you can use the following property:

Declare

Begin

FBean.set_property('HTMLEDITOR_AREA',1,'enabled','true');
End;


To verify if the document has been edited:

Declare
vEdited boolean;
Begin

vEdited := FBean.Get_Bool_Property('HTMLEDITOR_AREA',1,'documentEdited');
if vEdited then
:block3.TEXT_AREA := 'documentEdited=true';
else
:block3.TEXT_AREA := 'documentEdited=false';
end if;

End;