JSF application (on Apache MyFaces, then version 0.3) • CEO of IRIAN, a consultant house specialized on Java, web-apps and JSF (based in Vienna) • member of the JSF 2.0, Webbeans, JSF Metadata, JSF Portletbridge expert groups • Committer of Apache MyFaces, Facelets, Apache member • Consultant @Credit Suisse • rebuilding the 3rd largest app-suite of CS with (cs)JSF • writes books on web-frameworks (e.g. JSF, GWT, Rails) • frequently speaks on JSF and web-application development
When you have found all of them • after the main content start slide (Servlet 3.0) • On my slides – not surfing the web .. • You stand up and scream: „Buzzword Bingo“ • If nobody stands up until I show the next slide, my girlfriend will get everything • The winner takes it all:
partially extend from Facelets-classes? • yes – you can keep the old Facelets-jars and configuration • set javax.faces. DISABLE_FACELET_JSF_VIEWHANDLER • no – you don't need Facelets old anymore
• after restore view, you always have access to the full component tree • Facelets Composite comp = always a UIComponent instance • what if you don't want this? • currently under discussion • transparent components • (Optional) Metadata you can use Action-methods directly! Yay!
id="submit" value="submit" partialSubmit="true" partialGroups="grp1, grp2"/> You embed a child element for more configuration options: <h:commandButton> <f:ajax execute="grp1, grp2" render="grp1, grp2"/> </h:commandButton>
• execute: group of ids • render: group of ids • onevent: javascript to be executed • onerror: javascript to be executed on error • disabled: should this behavior execute or not? • listener: server-side method expression to be called
var viewState = javax.faces.Ajax.viewState(form); <h:commandButton id="submit" value="submit" onclick="javax.faces.ajax.ajaxRequest(this , event, {execute:'submit',render:'outtext'}); return false;" /> last option: associative array, keys: "execute", "render", values – component-ids to be executed or rendered javax.faces.Ajax.ajaxResponse(request); - called when everything is done to update DOM
into the lifecycle • only these portions will be executed • processDecodes, ...Validators, ...Updates, render-methods need to take the following information into account: FacesContext.isAjaxRequest() FacesContext.getExecutePhaseClien tIds();
An attached object like converter/validator • Behaviors allow to send scripts to the client • Also take part in decoding String getScript(BehaviorContext c); void decode(fc, UIComponent co); String getRendererType(); void broadcast(BehaviorEvent ev); Set<String> getHints();
components from the template in the beginning • tell the components when they have been built Initial or eden-state • components remember only stuff on top of this • internal storage: maps (with a property-key) • my estimate: less then 1/10 of current application state
anymore, if no special overrides • whatever is set to the map after Eden-State callback is automatically restored/saved • restore/save the state per component - independent • not by passing in a bloated object[ ] to the root Tree Visitor
• does not work with structured components (flyweight-pattern) • Therefore, there is now a visitor: – UIComponent.visitTree(VisitContext ctx, VisitCallback contextCallback);
own components • no restoreState / saveState need to be implemented • prepare an enum which keys the attributes enum Keys { rendered, collapsed, disabled }
be handled: • at the end of each lifecycle-phase • Exception-handler class: • void handle() throws FacesException • the exception-handler can be decorated • register exception handler factory in faces- config
(square brackets means optional): [localePrefix/][libraryName/] [libraryVersion/]resourceName[/resourceVersion] • This will be evaluated relative to either: • web-application-root/resources (means call to externalContext.getResource()) • classpath:/META-INF/resources (means call to getContextClassLoader().getResource())
• Resource resource = resourceHandler.createResource(Strin g resourceName, String libraryName) • String path = resource.getRequestPath(); • versions are automatically resolved (the last version is taken)!
• <h:graphicImage value="#{resource[‘images:Planets.gi f’]}"/> • certain tags will have new attributes: <h:graphicImage name="Planets.gif" library="images"/> • new tags (supporting attr target, see later): <h:outputScript /> <h:outputStylesheet/>
to specify a relocation • target="head" relocates to head • for this: – h:head / h:body • special renderers for head and body • resource-renderers (for script, stylesheet, etc. references)
class ScriptRenderer extends Renderer implements ComponentSystemEventListener puts UIOutput with this renderer-class to <f:facet name="head"> under UIViewRoot
Application System Events • Component System Events • Can be queued on: • Application.subscribeToEvent(); • Component.subscribeToEvent(); • or with annotations: • @ListenerFor and @ListenersFor • Components, Renderers, Validators, Converters can use this
<h:outcomeTarget value="Link text" outcome="nextPage" /> • Evaluates the navigation-system immediately and returns the following page • To still have some dynamics – nest an <if>EL-expression</if> – inside navigation-case • GET-URL is rendered
<f:pageParam value="param1" target="#{bean.param1}"/> </f:metadata> • embedded in the <f:view/> tag • if you use templating, you will need to put a ui:insert/ui:define combination at this location
modularization: faces servlet might be auto- registered by default • asynchronous servlets: • before invoke application • prevention of thread starvation • and support of asynchronous backends • faces servlet: • startAsync(): store FacesContext in request- map • restore it when the request is continued
getCurrentComponent(fc) • public static UIComponent getCurrentCompositeComponent(fc) • stored in FacesContext.getAttributes() • under key: javax.faces.component.CURRENT_COMPON ENT
current phase-id • enableResponseWriting(); - lift/set down the pen for rendering • getAttributes(); - a map of generic attributes • isPostback(); - is the request a post-back? • getPartialViewContext() - AJAX-related info
is a new view-map • provides a view-scope to the application • data stored in this scope will be available as long as a view is available • you can put a managed-bean in scope: view