Web Components is a collection of four specifications to create reusable user interface components. These different technologies are Custom Elements, Shadow DOM, Html Imports and Templates. Modern browsers provide native implementations and javascript libraries called pollyfills are available to use them on older browsers. There are some libraries to create web components easily such as Google Polymer or Mozilla X-Tag while providing additional features.
PrimeElements is an add-on library for PrimeUI that only uses the Custom Elements technology. PrimeElements are based on X-Tag APIs, a simple and lightweight library to create cross browser custom elements.
PrimeElements is a library not a framework, features such as data binding, validation, routing are out of scope since they can be provided by your framework of choice. As they are regular html elements, there are various use cases including integration with a simple REST backend, a javascript mvc framework or implementation in a server side rendering web framework such as PHP, JSP, RoR, Django, ASP.NET MVC, Spring MVC, JavaEE MVC and many more. Advanced cases such as hybrid mobile apps and offline support is also possible since there is no dependency to a server side api.
<select id="basic" name="basic"> <option value="0">Select One</option> <option value="1">Option 1</option> <option value="2">Option 2</option> <option value="3">Option 3</option> </select>
$('#basic').puidropdown();On the contrary, elements are created using their tags without need of an initialization script.
<p-dropdown> <option value="1">Option 1</option> <option value="2">Option 2</option> <option value="3">Option 3</option> </p-dropdown>
var dropdown = document.createElement('p-dropdown');
<button type="button" id="btn">Save</button>
$('#btn').puibutton();
<button is="p-button" type="button" id="btn">Save</button>
<button type="button" is="p-button" icon="fa-external-link" onclick="document.getElementById('dlgelement').show()" >Show</button> <p-dialog id="dlgelement" title="Dialog Header" modal showeffect="fade" hideeffect="fade" draggable resizable> <p>Dialog content here.</p> </p-dialog>
Dialog content here.
<div id="tbl"></div>
$('#tbl').puidatatable({ caption: 'List of Cars', paginator: { rows: 10 }, columns: [ {field: 'vin', headerText: 'Vin', sortable: true, filter: true}, {field: 'brand', headerText: 'Brand', sortable: true, filter: true}, {field: 'year', headerText: 'Year', sortable: true, filter: true}, {field: 'color', headerText: 'Color', sortable: true, filter: true, content: function(car){return $(<span style="color:{{color}}">{{color}}</span>);}} ], datasource: function(callback) { $.ajax({ type: "GET", url: 'showcase/resources/data/cars-large.json', dataType: "json", context: this, success: function(response) { callback.call(this, response); } }); }, selectionMode: 'single' });PrimeElement shortens the code required using p-datatable and p-column elements.
<p-datatable datasource="Showcase.demo.loadAllCars" paginator rows="10" selectionmode="single"> <p-column field="vin" headertext="Vin" sortable filter></p-column> <p-column field="year" headertext="Year" sortable filter></p-column> <p-column field="brand" headertext="Brand" sortable filter></p-column> <p-column field="color" headertext="Color" sortable filter> <template> <span style="color:{{color}}">{{color}}</span> </template> </p-column> </p-datatable>
<div id="tabview"> <ul> <li><a href="#tab1">Tab 1</a></li> <li><a href="#tab2">Tab 2</a></li> <li><a href="#tab3">Tab 3</a></li> </ul> <div> <div id="tab1"> Tab 1 Content </div> <div id="tab2"> Tab 2 Content </div> <div id="tab3"> Tab 3 Content </div> </div> </div>
$('#tabview').puitabview();And the PrimeElement version.
<p-tabview> <p-tab title="Tab 1"> Tab 1 Content </p-tab> <p-tab title="Tab 2"> Tab 2 Content </p-tab> </p-tabview>
<p-rating stars="10" onrate="MyApp.handleRate"></p-rating>
var MyApp = { handleRate: function(event, value) { //value = new rating value } };
In addition to the free themeroller based themes, PrimeElements support premium layouts and themes as well to give the elements a great look and a responsive template to work within.
PrimeElements drastically reduce the amount of work required to create nice looking and functional UIs by providing a rapid application development kit based on standard Web Components technologies. Maintenance effort also benefits from this as there is less amount of script involved.