Knowledgebase Home Page  >  RapidSpell Web Java
Search the Knowledge Base
Add spell checking control to an Oracle ADF web application
https://keyoti.com/kb/Default.aspx?ToDo=view&questId=272&catId=45

Options

Print this page
Email this to a friend

RapidSpell Web Java has a Javascript client mode that works with most if not all client web frameworks, including ADF.  It automatically sets itself up to spell check all textboxes on a page (specific textboxes can be ignored/included).

To use this article you should first download RapidSpell Web Java (if not already), then follow the Installation section of the help to integrate RapidSpell with your project.

Using RapidSpell Web Java in Javascript mode on ADF is the same as using it on other frameworks, so you can use the examples from the RapidSpell  help, but with one change related to the servlet registration, which is explained below.

In the installation section of the RapidSpell help, there are instructions for registering the servlet for URLs matching a.rapidspellweb.  ADF also registers a servlet for all requests to URLs with /Faces/ in it, which means that if our a.rapidspellweb servlet is requested under /Faces/a.rapidspellweb then its response will be broken by the ADF servlet (ADF outputs loopbacks etc).

To avoid this problem, you just need to explicitly specify that a.rapidspellweb should be loaded from a folder above /Faces. 

Eg. if your app is called “SpellCheckTest”, and has URLs like http://host/SpellCheckText/Faces/..., then specify a.rapidspellweb URLs as being directly under /SpellCheckText/.  In the page below, look for the following lines of code:

<af:resource type="javascript" source="/SpellCheckTest/a.rapidspellweb?t=r&amp;n=RapidSpell-DIALOG.js"></af:resource>

<af:resource type="javascript" source="/SpellCheckTest/a.rapidspellweb?t=r&amp;n=RapidSpell-AYT.js"></af:resource>

rapidSpell.ayt_helperURL ="/SpellCheckTest/a.rapidspellweb?t=a";

rapidSpell.dialog_popupURL="/SpellCheckTest/a.rapidspellweb?t=d";

These ensure RapidSpell’s servlet is loaded above /Faces/.

Below is a complete working example, of RapidSpell Web Java working with Oracle ADF.  There is also a chunk of onPageLoad script which needs to be added because ADF does not honor existing onload handlers.

<?xml version='1.0' encoding='UTF-8'?>

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"

          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">

    <jsp:directive.page contentType="text/html;charset=UTF-8"/>

    <f:view>

        <af:document title="TestSpellCheck.jspx" id="d1">

        

          <!--Register this so that onPageLoad function below will run-->

          <af:clientListener method="onPageLoad" type="load"/>

          <f:facet name="metaContainer">

            <!--It is important to use the root URL for the a.rapidspellweb import.  Doing this prevents the Faces servlet from

            processing the RapidSpell Servlet response (and breaking it).

            In other words, if you import source="a.rapidspellweb?t=r&amp;n=RapidSpell-DIALOG.js", it will NOT work because the

            browser will request /<root>/Faces/a.rapidspellweb?t=r&amp;n=RapidSpell-DIALOG.js, which will trigger the Faces

            Servlet to run the ADF loopback, breaking RapidSpell functionality.-->

            <af:resource type="javascript" source="/SpellCheckTest/a.rapidspellweb?t=r&amp;n=RapidSpell-DIALOG.js"></af:resource>

            <af:resource type="javascript" source="/SpellCheckTest/a.rapidspellweb?t=r&amp;n=RapidSpell-AYT.js"></af:resource>

           

           

           <af:resource type="javascript">/*<![CDATA[*/

              /*We must call all this code because ADF doesn't play nice with our load handler.*/

              function onPageLoad(evt) {

                  /*See above comment about root URL and Servlets*/

                  rapidSpell.ayt_helperURL ="/SpellCheckTest/a.rapidspellweb?t=a";

       rapidSpell.dialog_popupURL="/SpellCheckTest/a.rapidspellweb?t=d";

               

                    if (rapidSpell.ayt_staticMode) {

                        rsw_setupTextBoxes();

                        return;

                    }

                   

                

                

                    rsw_setupTextBoxes();

                    if (rsw_AYT_oldEvt) rsw_AYT_oldEvt();

                    rsw__init();

                   

                    rsw_attachInitHandler();

                    if (rsw_oldOnload) rsw_oldOnload();

                    rsw_MenuOnRightClick = true;

                    var newDIV = document.createElement("div");

                    newDIV.setAttribute("id", "RS_CM_DIV");

                    newDIV.setAttribute("style", "visibility:hidden;");

                    newDIV.setAttribute("oncontextmenu", "try{event.cancelBubble=true;event.preventDefault();}catch(e){}return false;");

                    newDIV.oncontextmenu = function () { try { event.cancelBubble = true; event.preventDefault(); } catch (e) { } return false; };

                    document.body.appendChild(newDIV);

               

                    var newIF = document.createElement("iframe");

                    newIF.setAttribute("id", "RS_CM_IF");

                    newIF.setAttribute("src", "javascript: false;");

                    newIF.setAttribute("scrolling", "no");

                    newIF.setAttribute("frameborder", "0");

                    newIF.setAttribute("style", "position:absolute; top:0px; left:0px; visibility:hidden;");

                    newIF.style.display = "none";

                    document.body.appendChild(newIF);

       

              }

          

              //]]>

            </af:resource>

          </f:facet>

            <af:form id="f1" clientComponent="true">           

                <af:panelGroupLayout id="pgl1" clientComponent="true">

                    <af:inputText label="Label 1" id="it1" rows="5" columns="50" clientComponent="true"/>

                    <af:button text="Dialog spell check" id="b1" clientComponent="true">

                       <af:clientListener method=" rapidSpell.dialog_spellCheck()" type="action"/>

                    </af:button>

                </af:panelGroupLayout>

            </af:form>

        </af:document>

    </f:view>

</jsp:root>

 

 

 


Related Questions:

Attachments:

No attachments were found.