-
Notifications
You must be signed in to change notification settings - Fork 207
Architectural overview
AJAX Solr loosely follows the Model-view-controller pattern. The ParameterStore is the model, storing the Solr parameters and, thus, the state of the application. The Manager is the controller; it talks to the ParameterStore, sends requests to Solr, and delegates the response to the widgets for rendering. The widgets, along with any theme functions, are the views, each rendering a part of the interface.
The Manager takes as a parameter either solrUrl – if talking to Solr directly – or proxyUrl – if talking to Solr through a proxy. (Usually, you want to talk to the instance through a proxy, so as not to expose the Solr instance to the Internet.) solrUrl must be the absolute URL to the Solr select servlet, or equivalent.
Manager = new AjaxSolr.Manager({
solrUrl: 'http://example.solrstuff.org/solrjs/select',
});
The ParameterStore and the widgets attach themselves to the Manager with the setStore and addWidget methods, respectively. The Manager is, effectively, a container for all AJAX Solr object instances.
Manager.setStore(new AjaxSolr.ParameterStore());
Manager.addWidget(new AjaxSolr.AbstractWidget({
id: 'identifier',
target: '#css-selector'
}));
Once these are attached, the Manager’s init method is typically called, to initialize AJAX Solr. init also calls the init methods of the ParameterStore and widgets:
Manager.init();
Having initialized AJAX Solr, the Manager’s doRequest method is typically called, to send the first request to Solr:
Manager.doRequest();
doRequest calls each widget’s beforeRequest method, in case any widget wishes to perform some action before the request is sent to Solr, e.g. display a throbber. It then calls the executeRequest abstract method to send the request. AJAX Solr is JavaScript framework-agnostic; it only requires an AJAX implementation to send requests to Solr. AJAX Solr is distributed with a Manager.jquery.js file, which implements the executeRequest method using jQuery. Once the Manager receives a response from Solr, it caches the JSON response in its response property, and calls each widget’s afterRequest method, in which widgets will inspect the response and update the interface accordingly.
The ParameterStore holds the state of the application.
Widgets inspect the JSON response retrieved from Solr by the Manager and update the interface accordingly.
- core/ includes all framework-agnostic managers, parameter stores, and abstract widgets.
- managers/ includes all framework-specific managers.
- widgets/ includes all framework-specific widgets.
- helpers/ includes optional theme functions.
Each JavaScript “class,” e.g. AbstractManager, is defined it its own file.
Everything AJAX Solr is implemented within the AjaxSolr namespace.