Primefaces: Next Generation Component Suite
Primefaces: Next Generation Component Suite
Cagatay Civici
Yigit Darcin
Prime Technology
• Agile and Java EE Consulting
• Java EE (JSF, Spring, EJBs, CDI, JPA)
• Trainings (e.g. Java EE, PrimeFaces)
• Outsource Development
• Istanbul/Turkey based
• Turkcell Projects: AdServer, Gezenzi
What is this about?
• JSF Overview
• PrimeFaces Component Suite
• RIA
• Ajax Push
• TouchFaces
• iPhone/Android/Palm
• GPS Navigation
• Mock OS X with JSF
JSF Overview
• Standard Web Framework for Java EE
• MVC
• Component Oriented
• Event Driven
• Current 2.0
• Vendor Support
Vendor Support
• Apache MyFaces
• Oracle ADF Faces and Mojarra
• PrimeFaces
• Spring WebFlow
• JBoss Seam, RichFaces
• IceFaces
• Java EE 6 (CDI, Bean Validation)
Basic JSF
<h:form>
Username: <h:inputText value=”#{loginBean.username}” />
Password: <h:inputText value=”#{loginBean.password}” />
<h:head>
!
</h:head>
<h:body>
! <p:editor />
<h:body>
</html>
Unobstrusive UI
JSF Markup
<p:schedule id=”calendar ” value=”#{bean.value}” editable=”true”/>
HTML Markup
<div id=”calendar”></div>
<script type=”text/javascript”>
new PrimeFaces.widget.Schedule(‘calendar’, {editable:true});
</script>
Output
Easy Ajax
• Ajax without complexity
• Partial Page Rendering
• Flexible with Callbacks (e.g. onstart,
oncomplete)
• Ajax components (e.g. autoComplete)
• Lightweight, No overhead
PPR - Hello World
public class GreetingBean {
private String name;
//...
}
<h:form>
<h:inputText value=”#{greetingBean.name}” />
<h:outputText id=”name” value=”Hi: #{greetingBean.name}” />
<h:inputText value=”#{greetingBean.name}”>
<p:ajax event=”blur” update=”name” />
</h:inputText>
process=”@this”
Partial Processing - Case 1
<h:form>
<h:inputText id=”I_AM_REQUIRED” required=”true” />
<h:selectOneMenu id=”cities”>
<p:ajax update=”cities” process=”@this” />
</h:selectOneMenu>
Apply Request
Process Validations
Update Model
Invoke App
Update Render
Notifying Users
• Declarative
<p:ajaxStatus>
! ! <f:facet name="start">
! ! ! <p:graphicImage value="fancyanimation.gif" />
! ! </f:facet>! !
! ! <f:facet name="complete">
! ! ! <h:outputText value="Request Completed" />
! ! </f:facet>
</p:ajaxStatus>
• Programmatic
<p:ajaxStatus onstart=”alert(‘Started’)” oncomplete=”alert(‘done’)” />
Global vs Non-Global
• To trigger p:ajaxStatus or not
<p:ajaxStatus>
! ! <f:facet name="start">
! ! ! <p:graphicImage value="fancyanimation.gif" />
! ! </f:facet>! !
! ! <f:facet name="complete">
! ! ! <h:outputText value="Request Completed" />
! ! </f:facet>
</p:ajaxStatus>
• Lightweight
• Keep it clean
Component Suite Demo
Themes
• Integrated with ThemeRoller
• 30 Built-in Themes
• Online tool to create your own
Themes
Themes
• No need to know CSS
• http://vimeo.com/14235640
TouchFaces
• Mobile UI Kit
• WebKit Browsers
• IPhone, Android, Palm
• Native IPhone UI
• Integrated Ajax
• Regular JSF
• Powered by jqTouch
TouchFaces UI
• <i:application />
• <i:view />
• <i:tableView />
• <i:rowGroup />
• <i:rowItem />
• <i:switch />
TouchFaces in Action
<h:form>
<h:inputText value=”#{chatController.message}” />
<p:commandButton value=”Send” actionListener=”#{chatController.send}” />
</h:form>
<p:outputPanel id=”display” />
<script type=”text/javascript”>
function handlePublish(pushed) {
! $('#display').append(pushed.data);
}
</script>
Pushing as JSON
Player player = new Player();
player.setName(“Messi”);
player.setAge(22);
CometContext.publish(player);
function handlePublish(pushed) {
//pushed.data.name;
//pushed.data.age;
}
Ajax Push Demo
Extensions: FacesTrace
• Trace/Debug tool
• Lifecycle visualizer
• Performance Tracker
• Visual component tree
FacesTrace Demo
Integrate With
• Spring
• Spring Webflow
• EJB
• Seam
• CDI
• Portlets
• GAE
• See svn/examples
Documentation
• User’s Guide - 440 pages
• Wiki
• Screencasts
• API & TLD Docs
• Third party articles/blogs
• PrimeFaces Book (McGraw Hill) - Soon
Community Support
• http://primefaces.prime.com.tr/forum
Enterprise Support
• Onsite support
• Priority forum access
• JSF specific help
• Special Case Support
Popularity
• Thousands of Users
• 1000+ posts per week in forum
• 14000+ downloads in 5 weeks, 2.2.RC2
• Invited to international conferences
Who Uses
Questions