One of the solutions could be as follows:
RichFaces components API will be exposed on Bridges instead of components:
var bridge = ...;
var autocomplete = this.input.data('autocomplete')
$.each(autocomplete, function(key, value) {
// for public methods
if (key.indexOf('_') !== 0) {
bridge[key] = function() {
autocomplete[key].apply(autocomplete, arguments);
}
}
}
This could be even generalizes to bridge-base.js.
Then, once we reference public methods from widget and expose them to
bridge,
we could simplify RichFaces.component method.
Finally, we could expose JSF-facing JavaScript API methods on the bridge:
{
setValue : function(value) {
autocomplete.input.val(value);
}
}
~ Lukas
On Wed, Nov 27, 2013 at 3:20 PM, Lukáš Fryč <lukas.fryc(a)gmail.com> wrote:
Hey guys,
I have found a following issue:
we expose public JSF component API for Widget Factory based component by
allowing to reference widget reference (i.e. call methods directly on
widget instance):
#{rich:component('autocomplete')}.close();
It will make sure that e.g. following methods can be invoked:
http://www.richwidgets.io/api/classes/autocomplete.html
But those methods doesn't have to be as rich as JSF component we had in
RF4.
E.g. in Autocomplete, we had methods getValue() and setValue().
Those methods doesn't do anything else than setting an appropriate value
to the input field. In order to allow unified API, we could expose those
methods for RF5 Autocomplete as well, which will be just syntactic sugar in
terms of Widget Factory -based API.
WDYT?
~ Lukas