what's new and exciting with jsf 2.0
DESCRIPTION
This presentation (best viewed with the notes view in ppt, individually) is an overview of new features of JSF 2.0.TRANSCRIPT
![Page 1: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/1.jpg)
Increasing JSF’s vitality with version 2.0 enhancements
By Michael FonsADF DeveloperSquareTwo Financial
![Page 2: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/2.jpg)
Many JSF developers were not thriving with JSF 1.x.
![Page 3: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/3.jpg)
Java professionals worldwide invigorated the JSF 2.0 redo.
![Page 4: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/4.jpg)
JSF 1.x turned out to be weak, and needed to become more fit.
![Page 5: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/5.jpg)
JSF 2.0 has infused JSF with life and given JSF back its edge.
![Page 6: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/6.jpg)
The Java EE community builds its health by adopting JSF 2.0!
![Page 7: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/7.jpg)
Features like Facelets, Navigational changes, and Ajax strengthen JSF.
![Page 8: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/8.jpg)
Facelets creates many strong capabilities.
![Page 9: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/9.jpg)
Facelets makes templating straightforward.
ui:composition,
ui:define,
ui:decorate, and
ui:insert
![Page 10: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/10.jpg)
Developers can easily create composite components now.Caller page:<xyz:myComp …> <f:validateLength for=“myClientId” …/></xyz:myComp>Composite component Interface section:<cc:editableValueHolder name=“myClientId”…/>Composite component Implementation:<h:inputText … id=“myClientId”/>
![Page 11: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/11.jpg)
Using XHTML now eliminates scriptlets.Not allowed <% …java code … %>
Only XHTML allowed.
![Page 12: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/12.jpg)
JSF 2.0 implements Ajax in a natural way.
![Page 13: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/13.jpg)
Tiny syntactical changes tap into lots of Ajax capability.Non-AJAX
<h:form>
<h:inputText …/>
<h:commandButton …/>
</h:form>
Using AJAX<f:ajax …><h:inputText …/></f:ajax>OR<h:form><h:inputText …><f:ajax render=“@form”/></h:inputText></h:form>
![Page 14: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/14.jpg)
Developers do not need any JavaScript in many cases. <h:form id="form"><!-- ******M E T H O D 1********** --> <h:outputText id="output" value="You entered #{requestScope['input']}."/> <h:inputText id="input“ value="#{requestScope.input}”> <f:ajax render="form:output“ event="keyup"/> </h:inputText></h:form>
![Page 15: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/15.jpg)
A developer can still implement any custom Ajax solution.<h:form id="form"><!-- *******M E T H O D 2******** --> <h:outputText id="output2" value="You entered #{requestScope['input2']}."/> <h:inputText id="input2" value="#{requestScope.input2}" onkeyup="var lArgs = {}; lArgs['render'] = 'form:output2'; lArgs['javax.faces.behavior.event'] = 'keyup'; jsf.ajax.request(this,event,lArgs);”> <!-- If I did not want to change from the default event for the inputText, the call would be jsf.ajax.request(this, event, {render:’form:output2’}); but I want to change the event, and they have named that property with periods in it. in jsf.js line 1659 I am getting an error because there is a syntax problem when I set javax.faces.behaviour.event property to keyup because the periods in the property name throw the js interpreter off-->
</h:inputText></h:form>
![Page 16: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/16.jpg)
The navigation makes JSF 2.0 friendlier.
![Page 17: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/17.jpg)
Implicit navigation makes navigation easier.
…To go to page xyz.xhtml,
you can use…
<h:comandButton action=“xyz” … />
![Page 18: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/18.jpg)
Post-redirect-get and bookmarkability strengthen JSF.
POST method:
<h:commandButton/> OR
<h:commandLink/>
GET method:
<h:button/> OR
<h:link/>
![Page 19: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/19.jpg)
Flash supplements JSF navigation.Using EL:#{flash.someVariable}…to keep what is already stored there for another request…#{flash.keep.someVariable}
Using Java:Flash lFlash = FacesContext.getCurrentInstance().getExternalContext().getFlash();lFlash.get(“someVariable”);
![Page 20: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/20.jpg)
JSF 1.1/1.2 have lost favor due to their unhealthiness.
![Page 21: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/21.jpg)
Events, Components, and Exception Handling invigorate JSF.
![Page 22: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/22.jpg)
Expanded System Events allows precision placement of logic.
![Page 23: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/23.jpg)
Application create/destroy and exceptions now all create events.<application> <system-event-listener> <system-event-listener-class>mfons.experiments.jsf20.TestPostConstructApplicationEventListener</system-event-listener-class> <system-event-class>javax.faces.event.PostConstructApplicationEvent</system-event-class> </system-event-listener> <system-event-listener> <system-event-listener-class>mfons.experiments.jsf20.TestPostConstructApplicationEventListener</system-event-listener-class> <system-event-class>javax.faces.event.PreDestroyApplicationEvent</system-event-class> </system-event-listener></application>
![Page 24: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/24.jpg)
Component events now include AJAX, validation, and state.…this statement…<f:ajax … listener="#{myBean.checkAjaxBehavior}"/>…creates this event for each Ajax event for the components to which this f:ajax tag applies… public void checkAjaxBehavior(AjaxBehaviorEvent pEvent){ System.out.println("This inputText has Ajax behavior and it is right now undergoing a decode method call in the request values phase of the JSF request lifecycle"); }
![Page 25: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/25.jpg)
Removal from view and scope changes increase events.Good reference to know when PostAddToViewEvent and PreRemoveFromViewEvent are fired:
https://issues.apache.org/jira/browse/MYFACES-2638
![Page 26: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/26.jpg)
JSF 2.0 heals custom components development.
![Page 27: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/27.jpg)
Beginners can quickly combine components to make their own.A using page references…xmlns:<library reference>=http://java.sun.com/jsf/composite
</optional library name>
…and will reference…<lr:xyz …/>
…if the library reference is “lr” and the name of the definition file is “resources</optional library name>/xyz.xhtml”
![Page 28: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/28.jpg)
Intermediates can add much complexity simply in most cases.<cc:interface>
<cc:attribute name=“someattr”/>
<cc:editableValueHolder … />
<cc:actionSource … />
</cc:interface>
<cc:implementation>
<h:outputText value=“#{cc.attrs.someattr}”/>
</cc:implementation>
![Page 29: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/29.jpg)
JSF 2.0 still has its old custom component options for experts.Non-composite component authors define…
…UIComponent Java class
…Facelets tag library
…Renderers
…tag handlers
Easier state management, now…
![Page 30: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/30.jpg)
Exception handling increases JSF’s IQ.
![Page 31: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/31.jpg)
Unhandled errors are disruptive to an application.Nobody wants to hear…
NOTHING IS WORKING!!!!
![Page 32: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/32.jpg)
Having a consistent error handling interface is calming....in faces-config.xml…
You can redefine
ExceptionHandlerFactory
![Page 33: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/33.jpg)
Now global error-handling schemes can be found.The custom
ExceptionHandlerFactory
Can provide…
A custom ExceptionHandler
![Page 34: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/34.jpg)
JSF 1.1/1.2 have lost favor due to their unhealthiness.
![Page 35: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/35.jpg)
State Saving, View Parameters, and Resources revitalize JSF.
![Page 36: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/36.jpg)
Toned State Saving improves JSF.
![Page 37: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/37.jpg)
The partial state feature minimizes the state saved.Thanks,
Adam
Weiner!
![Page 38: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/38.jpg)
Component developers enjoy the simpler syntax.StateHelper has
Eliminated
The need for…
saveState() and
restoreState()
@Overrides!
![Page 39: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/39.jpg)
Developers now say when a component has its initial state.PartialStateHolder.markInitialState()
is needed for component developers.
![Page 40: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/40.jpg)
View Parameters increase JSF developers’ options.
![Page 41: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/41.jpg)
Developers can declaratively define GET parameters.In caller page link/button outcome…
someoutcome?faces-redirect=true&includeViewParams=true
In target page…
<f:metadata>
<f:viewParam …/>
</f:metadata>
![Page 42: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/42.jpg)
The parameters implement EditableValueHolder.…can write to model…
<f:viewParam name=“something”
value=“#{some.valueExpression}” />
…can invoke application logic…
<f:event type=“preRenderView”
listener=“#{some.preRenderViewEventListenerMethod}”/>
![Page 43: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/43.jpg)
You can create bookmarkable links with these parameters.…supports bookmarkability…
<h:link …/>/<h:button …/>
…example:
<h:link outcome=“currentPageName?faces-redirect=true&includeViewParams=true” value=“bookmarkable link to this page”/>
![Page 44: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/44.jpg)
JSF 2.0 power-lifts resource access for custom components.
![Page 45: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/45.jpg)
JSF 2.0 easily serves resources to custom components.@FacesRenderer(rendererType = “…", componentFamily = “…")@ResourceDependencies({ @ResourceDependency(name = “mycss.css", library = “mystyle", target = "head"), …})public class MyRenderer extends Renderer { …
![Page 46: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/46.jpg)
Developers can install new resource versions instantly.In resources directory…
[localePrefix/][libraryName/][libraryVersion/]resourceName[/resourceVersion]
…where [ ] indicate optionality
![Page 47: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/47.jpg)
Resource files will now reside in predictable locations.…either in docroot:
/resources/…
…or in
META-INF/resources/…
…somewhere on the classpath.
![Page 48: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/48.jpg)
Has the JSF 2.0 team detoxified JSF 1.x?
![Page 49: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/49.jpg)
JSF 1.1/1.2 have lost favor due to their unhealthiness.
![Page 50: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/50.jpg)
The Java EE community builds its health by adopting JSF 2.0!
![Page 51: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/51.jpg)
Increasing JSF’s vitality with version 2.0 enhancements…
![Page 52: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/52.jpg)
JSF 2.0 is out, and it’s better than ever!
![Page 53: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/53.jpg)
Resources
http://blogs.sun.com/rlubke/entry/jsf_2_0_new_feature for help on resources.JavaServer Faces 2.0: the complete reference, by Ed Burns, Chris Schalk, McGraw-Hill, 2010.http://andyschwartz.wordpress.com/2009/07/31/whats-new-in-jsf-2/ http://javaserverfaces.java.net/nonav/docs/2.0/javadocs/javax/faces/component/PartialStateHolder.htmlhttp://blogs.sun.com/jasondlee/entry/jsf_2_gets_declarative_eventhttp://myfaces.apache.org/core20/myfaces-api/apidocs/javax/faces/event/ComponentSystemEvent.htmlhttp://weblogs.java.net/blog/edburns/archive/2009/09/02/jsf2-composite-component-metadatahttp://weblogs.java.net/blog/jhook/archive/2006/01/experiment_goin_1.htmlhttp://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-157http://www.slideshare.net/jimdriscoll/jsf-2-and-ajaxhttp://code.google.com/p/teknoatolye/source/browse/trunk/sinek/src/main/java/org/mca/sinek/jsf/SinekRenderer.javahttps://issues.apache.org/jira/browse/MYFACES-2638
![Page 54: What's new and exciting with JSF 2.0](https://reader037.vdocuments.mx/reader037/viewer/2022103016/5558329ed8b42acb078b4630/html5/thumbnails/54.jpg)
Contact Info:[email protected]