Francesco Strazzullo
http://www.francescostrazzullo.info/
http://www.e-xtrategy.net/
http://www.cosenonjaviste.it/
http://www.blogzinga.it/
https://www.facebook.com/groups/developermarche/
https://www.facebook.com/groups/650004995073683/
<h:commandButton value="Test"/>
<input type="submit" name="j_idt37:j_idt39" value="Test">
Server (*.jsf / *.xhtml)
Client (*.html)
JSF it's a component-based framework. Everything should be a component: from the basic input field, to a complete CRUD form.
Component : the object that holds the business logic of our component. (value,events, etc.)
Renderer : the object that render our component to HTML markup and grab value from the user.
Source: PrimeFaces blog :)
A complex Javascript component it's called widget . Every PrimeFaces widget extends a BaseWidget
Every component that we will create will extend BaseWidget too.
MaterialPrime.widget.Checkbox = PrimeFaces.widget.BaseWidget.extend({
init : function(cfg) {
this._super(cfg);
this.input = jQuery(this.jqId+"_input");
var that = this;
this.input.on("change",function(){
if(that.cfg.behaviors && that.cfg.behaviors.valueChange) {
that.cfg.behaviors.valueChange.call(that.input);
}
});
}
});
Every PrimeFaces renderer extends CoreRenderer . This class grant access to utility methods to create a widget in a very simple way.
private void encodeScript(FacesContext context, Checkbox checkbox) throws IOException {
String clientId = checkbox.getClientId();
String widgetVar = checkbox.resolveWidgetVar();
WidgetBuilder wb = getWidgetBuilder(context);
wb.initWithDomReady("Checkbox", widgetVar, clientId);
wb.attr("disabled",checkbox.isDisabled());
encodeClientBehaviors(context, checkbox);
wb.finish();
}
To create new component you can follow this workflow:
This "Framework" is an internal one, so there's no public documentation.
( Now you have this! :) )
http://www.mastertheboss.com/jboss-web/primefaces/extending-primefaces-components
http://www.francescostrazzullo.info/blog/2014/08/extending-primefaces-input-components/
http://www.mastertheboss.com/jboss-web/primefaces/extending-primefaces-ajax
http://goo.gl/forms/t73T4a4CrO
f.strazzullo@e-xtrategy.net
@TheStrazz86
https://github.com/primefaces-extensions/core
https://github.com/MaterialPrime/material-prime