[[how-to-implement-a-spellchecker]]
= How to implement a spellchecker?

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
:page-partial:



From this link:http://causeway.markmail.org/thread/dduarjscrbnodfsi[thread] on the Apache Causeway users mailing list:

* _What is the easiest way to add a spell checker to the text written in a field in
   a domain object, for instance to check English syntax?_

One way to implement is to use the xref:refguide:applib:index/services/eventbus/EventBusService.adoc[event bus]:

* Set up a xref:refguide:applib-classes:events.adoc#domain-event-classes[domain event] subscriber that can veto the changes.

* if the change is made through an action, you can use xref:refguide:applib:index/annotation/Action.adoc#domainEvent[@Action#domainEvent].

if if the change is made through an edit, you can use xref:refguide:applib:index/annotation/Property.adoc#domainEvent[@Property#domainEvent].

You'll need some way to know which fields should be spell checked.  Two ways spring to mind:

* either look at the domain event's identifier

* or subclass the domain event (recommended anyway) and have those subclass events implement some sort of marker interface, eg a `SpellCheckEvent`.

And you'll (obviously) also need some sort of spell checker implementation to call.

