Ajaxfrancelabs is deprecated as of Datafari v6.0 aside from specific admin and search expert functionalities. Please refer to DatafariUI for any search UI related task.

AjaxFranceLabs is a contribution from our company so that the community can manipulate Datafari through an Ajax Framework.

Spiritually, it is a child of the AjaxSolr framework, and you will see many similarities, in particular at the architecture level. The AjaxSolr has been a great source of inspiration for us.

Still, the code itself has been done from scratch (except for 2 classes which are almost copy pastes), as there were parts that were rather different, because of the differences between Datafari and Solr.

Although it is not part of the framework per se, we gave a particular care to the widgets that make use of our framework, because we know that you'll probably start with these widgets in order to get a hands on on our framework (you may even want to keep them as they are).

Code Structure

The framework contains the following folders:

A widget is a part of the user interface (UI) which is attached to a DOM element.
A module is an extension of the widgets.
Eg: my result widget displays all the documents found by the search query and my favorite module will add “stars” to those documents title in order to save them to my favorite documents.

Architecture diagram

The manager acts as a master controller. The widgets and modules are dealing with the manager in order to get the information they need and to modify the query request.

The parameter store stores the different parameter necessary to process the search query.

When a request query has to be processed, the manager calls a web service which receives the search query. This web service answers back to the manager, which stores the result in a variable (response) that the different components can access.

Class diagram

Core

AjaxFranceLabs offers different utility methods:

Sets the first letter of a word to upper case. The word is given as a parameter.

The main classes of the framework are:

Any class class has to extend one of these or the AjaxFranceLabs.Class. For this, use the .extend method provided by the AjaxFranceLabs.Class and any of the previous one.

Architecture of the main classes of the framework

AbstractManager

The manager is the main class of the framework. It is the master controller, the crossroad of all the information going in and out.
This class has to be extended in order to implement executeRequest() which have to make the call to the web service.

Insert architecture of the abstract manager here

Variables

connectionInfo: {
	autocomplete: {
		serverUrl: 127.0.0.1,
		servlet: 'select',
		queryString: 'callFunction=getInformations&type=user
	}
}

Methods

Parameter and ParameterStore

Insert architecture parameter/parameterstore

Parameter

Variables

Methods

ParameterStore

Variables

Methods

AbstractWidget

All the widgets have to extend the AjaxFranceLabs.AbstractWidget class or the AjaxFranceLabs.AbstractFacetWidget class.

AbstractWidget

Variables

Methods

AbstractFacetWidget

Variables

Methods

AbstractModule

Modules are extension of widgets, they will modify them once they are built.

Variables

Methods

Sequence diagram

Execution of a search query

  1. The element (widget, external user or program) triggers a request to the search web service from the manager using the method makeRequest()

  2. The manager first calls the beforeRequest() method of all the widgets and modules it controls. Thus the different widget can, for example, add parameters to the search query

  3. The manager then executes the search query on the web service using the method executeRequest() and wait for its response

  4. When the manager receives the response, it stores it into a local variable (reponse) accessible from all the widgets and modules it controls

  5. Finally, the manager executes the afterRequest() method of all the widgets and modules it controls, thus, they can update their data

Widget calling a web service

In order to illustrate this example, I will take the case of the AutocompleteWidget

  1. A user types some text in an input field which has an autocomplete widget attached to it

  2. The autocomplete widget retrieves the data entered by the user into the field and triggers the executeRequest() method from its manager to retrive the suggestions

  3. The manager answers to the autocomplete widget when it receives the results

  4. The autocomplete widget displays the results