Saturday, August 17, 2013

Tip of the day:including JQuery script in primfaces

Hay all,How are you

This is the first of many quick tips every developer should know while developing EJB/JSF Application.our first tip is about the common mistake that junior developer may do.They use JSF and Primfaces in their application,when they need some Java Script files relies upon JQuey,they supply a separate version of JQuey

Don't ever include your own version of JQuery while using primfaces,because primfaces already ships with jQuery/UI bundled.Supplying your own version would only risk malfunctioning of primefaces components because they rely on a different jQuery/UI version.

When supplying a custom JS file which relies upon PrimeFaces-supplied jQuery/UI, then you should place the <h:outputScript> at the End of the <h:body> instead of the <h:head>.This way it will be loaded after the PrimeFaces-supplied jQuery/UI is loaded. 
   <h:outputScript name="js/ui3.js" target="head" />  

Thanks BalusC for this great advice.