Integrating spell check into Text Area

9 posts / 0 new
Last post
gayathri
Offline
Joined: 01/12/2010
Integrating spell check into Text Area

Hi Vincent,

 

    I am using Flex as the UI and I want to integrate spell check into fields like comments, long description etc. I was looking SpellCheck an open source flex based component. Can you please give me direction on how to proceed integrating this into Jspresso or any other suggestions?

Thanks a  lot,

 

Regards,

Gayathri

 

vvandens
Offline
Joined: 05/29/2008
Integrating spell check into Text Area

Hi Gayathri,

You can change how fields/areas get rendered. Flex UIs are created on the fly based on a composition of faceless UI components that are assembled on the server by the DefaultRemoteViewFactory.
The AS3 (client) class responsible for materializing the flex UI is the org.jspresso.framework.view.flex.DefaultFlexViewFactory. You can inherit from it (let's call the subclass MyFlexViewFactory) and override the various methods responsible for creating the text components and use whatever specifics you need (instanciate and bind the components using bindable RemoteValueStates), i.e. :

  • createTextArea
  • createHtmlArea
  • createTextField

Then you have to make your Flex frontend use your specific view factory. Unfortunately, there is no DI on the client side, but it's not much of a trouble :

Create a subclass of the AS3 class org.jspresso.framework.application.frontend.controller.flex.DefaultFlexController (let's call it MyFlexController). Override the protected factory method createViewFactory() and return an instance of your specific MyFlexViewFactory.

Edit FlexApplicationStartup.mxml (the main flex application class generated by the archetype and thus belonging to your project sourcepath) and change the references to DefaultFlexController by references to MyFlexController.

You should be done.

PS: you  can use the [project root]/startup/flex/client maven module to create your AS3 classes (in src/main/flex). This way, they will be automatically included in the build.

HTH,
Vincent

gayathri
Offline
Joined: 01/12/2010
Integrating spell check into Text Area

Thanks Vincent for your prompt reply. I will give it a try and let you know how it goes.

 

Thanks a lot,

Gayathri

gayathri
Offline
Joined: 01/12/2010
Integrating spell check into Text Area

Hi Vincent,

   I apologise for the delay in this reply.

   I tried your suggestions. However the methods that you mentioned

  • createTextArea
  • createHtmlArea
  • createTextField

   are all private. Hence I get compilation error. I tried to override createComponent which is a public function. I am getting lots of compilation problems further.

 

  Also, I did not find createViewFactory() protected method. I saw that in the constructor _viewFactory was instantiated to DefaultFlexViewFactory.  I did not know how to reset the _viewFactory to MyFlexFactory().

   Hence I was wondering if the methods could be public or proctected so that we can override. Please let me know if you have any other suggestions.

 

Thanks

Gayathri

vvandens
Offline
Joined: 05/29/2008
Integrating spell check into Text Area

Hello Gayathri,

What you describe makes me think your are still compiling flex against Jspresso 3.0.0. I've opened all of the flex factory methods (making them protected) in the 3.0.1-SNAPSHOT.

Take a look at the online sources here :

DefaultFlexController.as

DefaultFlexViewFactory.as

 

You can also get a source zip archive if you need it from the Jspresso snapshots repository, i.e for the Flex module :

jspresso-flex-3.0.1-SNAPSHOT-sources.jar

 

HTH,

Vincent

gayathri
Offline
Joined: 01/12/2010
Integrating spell check into Text Area

Vincent,

Thanks so much for replying.

 Yes.. you were right. I was using 3.0.0 instead of 3.0.1.

  However, now I am running into another problem. The open source Spell Check that I am using uses a dictionary.dict file to match the spellings against. I tried putting this file under resources under flex and tried all combination of places. When I run the app, I get

[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:8080/riapp-webapp/flex/pub/dictionary.cdic"]. URL: http://localhost:8080/riapp-webapp/flex/pub/dictionary.cdic"]

From what I understand, this error happens when the resource cannot be found. I cracked open the war file. I noticed that pub/dictionary.cdic exist under WEB-INF/classes directory. I also tried putting under WEB-INF/classes/flex/pub/cdictionary.cdic.

I am really at a loss of ideas of where I should put the dictionary file. I am really sorry to be so ignorant.. Do you have ideas to proceed ?

Thanks again,

Gayathri

gayathri
Offline
Joined: 01/12/2010
Integrating spell check into Text Area

Vincent,

Thanks so much for replying.

 Yes.. you were right. I was using 3.0.0 instead of 3.0.1.

  However, now I am running into another problem. The open source Spell Check that I am using uses a dictionary.dict file to match the spellings against. I tried putting this file under resources under flex and tried all combination of places. When I run the app, I get

[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:8080/riapp-webapp/flex/pub/dictionary.cdic"]. URL: http://localhost:8080/riapp-webapp/flex/pub/dictionary.cdic"]

From what I understand, this error happens when the resource cannot be found. I cracked open the war file. I noticed that pub/dictionary.cdic exist under WEB-INF/classes directory. I also tried putting under WEB-INF/classes/flex/pub/cdictionary.cdic.

I am really at a loss of ideas of where I should put the dictionary file. I am really sorry to be so ignorant.. Do you have ideas to proceed ?

Thanks again,

Gayathri

vvandens
Offline
Joined: 05/29/2008
Integrating spell check into Text Area

Hi Gayathri,

From what I understand error message, you should have your dictionary.cdic file directly under /flex/pub/dictionary.cdic (not in WEB-INF nor WEB-INF/classes since it is not handled by the Java classloader but accessed directly from the client side).

Webapp static resources must go into webapp/src/main/webapp, so try to put the file in :

[your project root]/webapp/src/main/webapp/flex/pub/dictionary.cdic

It should be automatically packaged correctly and then accessible from the flex client component.

 

HTH,

Vincent

gayathri
Offline
Joined: 01/12/2010
Integrating spell check into Text Area

Hi Vincent,

    That was it.. Thanks so much.

Thanks

Gayathri