Mastering OmniFaces - A Problem to Solution Approach

Anghel Leonard
Anghel LeonardChief Technology Strategist
Anghel LeonardConstantin Alin
OmniFaces
is an utility library for JSF
and a comprehensive
compendium of
programming techniques,
design patterns and
recipes for JSF developers.
Inside this book, you will learn how to write robust, reusable
and easy to maintain JSF code with a high level of readability, efficiency and performance.
• learn how to use OmniFaces artifacts in your JSF projects
• understand how OmniFaces/JSF is implemented and how it works internally
• exploit the JSF API at a high level of development
• explore and write JSF programming techniques and design patt erns
• develop JSF reusable code
• identify and fix JSF gaps, pitfalls and bugs
• increase your arsenal of JSF helpers with more than 300 utilities methods
• learn how to write a considerable number of JSF custom artifacts types
• push your JSF skills to the limit and become a cutt ing edge developer
• crumble JSF myths and misconceptions by deeply understanding the framework
Chapter 1 - OmniFaces Components
Chapter 2 - OmniFaces Validators
Chapter 3 - OmniFaces Tag Handlers
Chapter 4 - OmniFaces Converters
Chapter 5 - OmniFaces Exception Handlers
Chapter 6 - OmniFaces Exception Contexts
Chapter 7 - OmniFaces Resource Handlers
Chapter 8 - OmniFaces Event Listeners
Chapter 9 - OmniFaces View Handlers
Chapter 10 - There's More
• registering a custom component for listening PostRestoreStateEvent
• programmatically extracting the value of an attribute
• searching components using relative‐up/down search algorithm
• collect the value of the label attribute for the given UI component
• setting an attribute value as a literal or as a value expression
• instructing an UIComponent to support a JSF converter
• sample of extending the ValueHolder interface (ParamHolder)
• having a quick overview of how to use StateHelper class
• introducing static vs. dynamic converters
• temporarily replacing the default output response (ResponseWriter)
• working with attributes of type var
• suppress the invocation of setValueExpression() for an attribute
• replacing/restoring the ResponseWriter in the rendering process
• carrying an artifact via the FacesContext attributes map
• putting an artifact in the request map (scope)
• programmatically indicating the renderer of a component
• indicating that a component will render its children also
• understanding the triplet: encodeBegin(), encodeChildren(), encodeEnd()
• programmatically collecting the available messages – FacesMessages
• discovering the OmniFaces utility, findComponentsInChildren()
• storing/removing something in/from request scope (request map)
• replacing/restoring something from/in request scope (request map)
• "postponing"/triggering the rendering of a component
• programmatically generating the markup of a HTML table/list
• working with the @ListenerFor annotation
• rendering the <script/> element
• determining if the current request is/isn t an AJAX requestʹ
• determining if the value of the render attribute is @all
• programmatically subscribe to view events (e.g. PreRenderViewEvent)
• using the OmniPartialViewContext for executing the given scripts on
completion of the current AJAX response
• marking a resource as rendered
• programmatically creating a Resource
• rendering the <script/> element when a resource exist
• rendering the <script/> element when a resource does not exist
• working with JSF VisitTree API
• access, from JS, the HTML markup via the client IDs provided by JSF
• transforming a stateful component into a stateless component
• suppressing decoding and validation at postback requests
• suppressing the built‐in required validator
• using the name attribute when the label attribute is absent
• working with the OmniFaces utility, MapWrapper
• working with several OmniFaces utility methods
• writing a custom FacesContext, Application and ViewHandler
• working with ViewHandler#getActionURL()
• encoding URLs
• programmatically control Process Validations phase
(via processValidators()) and Update Model Values
phase (via processUpdates())
• subscribing with a Callback to after Restore View phase
• a good example for understanding the JSF lifecycle
• JSF post‐processing tips
• subscribing with Callbacks to view/phase events
• working with BufferedHttpServletResponse
• introducing TagHandlers
• working with VariableMapper
• overriding UIComponent#isVisitable()
• programmatically loading the JSF AJAX library
• writing a custom UICommand
• extracting all UIParameters nested in a certain component
• validating if a component has a parent of a certain type
• resolve the given space separated collection of relative client IDs to
absolute client IDs
• creating and queuing an ActionEvent
• adding the autorun feature
• introducing “facelet scope”
• passing FaceletContext to a custom UIComponent
• storing a ValueExpression in the “facelet scope”
• storing a UIComponent in request scope
• subscribing to PreRenderViewEvent and PostRestoreStateEvent
• writing a custom ValueExpression
• working with ReadOnlyValueExpression
• writing a functional Callback
• finding a component in the component tree by client ID
• working with OmniFaces, validateHasNoChildren() utility method
• obtaining the environment‐specific object instance for
the current request/response
• building a buffered response via OmniFaces,
BufferedHttpServletResponse using the Servlets API RequestDispatcher
to includes the content of a resource
• understanding how JSF processes images
• working with JSF resource handlers
• writing a cacheable dynamic resource
• working with images request path
• understanding how “last modified” works
• obtaining/determining image content type
• obtaining the data URI from an image
• parsing/evaluating a ValueExpression and store
• converting a ValueExpression into a request path eligible for Reflection API
• parsing a request path and invoking a method using Java Reflection API
• testing the presence of an annotation on a class
• converting strings to objects using converters registered on given types
• converting objects to strings using converters registered on given types
• extending ViewParam
• processing request query parameters
• understanding decode() method goal
• suppressing validations and data model updates
• writing a custom PhaseListener
• learning about quick succession of writings
• turn off/on the original response writer
• moving components in the component tree
• moving facets and behaviors
• understanding how behaviors works in JSF
• implementing ClientBehaviorHolder
• subscribing to PreRenderViewEvent, and PostAddToViewEvent
• exploring several Tree use cases
• controlling the processDecodes(), processValidators(),
processUpdates() and the encodeChildren() from a single place (TreeFamily)
• using a "bunch" of OmniFaces utilities which are very handy in day
by day development
• following the JSF flow in a recursive implementation
• working with the "special" attributes, var and varNode
• exploring how the events are queued and broadcasted
• introducing javax.faces.FACELETS_SKIP_COMMENTS
• understanding the escape attribute role
• defining a Java reserved word as an enum item
• introducing Bean Validation
• obtaining the default message interpolator
• customizing the default message interpolator
• writing a template validator
• writing a template converter
• check if a component supports validators/converters
(is an instance of EditableValueHolder)
• programmatically obtain the model value of a component
• explicitly invoke the converter getAsString() method
• implement a custom validator
• programmatically check a component type
• programmatically locate a message bundle and access its keys
• implement a validator as a TagHander
• what s a JSFʹ new component in the component tree
• get the value of an attribute as a ValueExpression to be carried around and
evaluated later in the lifecycle without needing the Facelet context
• postpone a task before/after a JSF lifecycle phase of the current request
• get the closest parent of the given parent type
• write a SystemEventListener for PreValidateEvent and PostValidateEvent
• fired by UIInputs that have attached a BeanValidator
• finding a certain validator in the list of validators of a component
• programmatically point/replace/restore the BeanValidator validation groups
• use OmniFaces Copier API for copying objects
• traverse a form children and extract the ValueReference of each
EditableValueHolder for the specified base
• implementing a custom validator as a TagHandler that is registered as a
listener for ValueChangeEvent
• ValueChangeEvent internal overview
• JSF VisitTree implementation sample ‐ visit a JSF table rows (UIData iteration)
• tips for collecting the values of an UIInput component in an UIData component
• signaling invalid values
• "intercepting" Apply Request Values phase via processDecodes() method
• "intercepting" Process Validators phase via processValidators() method
• "intercepting" Update Model phase via processUpdates() method
• collecting inputs (and their values) from a form
• marking invalidation at component/context level
• associating the message bundle keys with components COMPONENT_TYPEs
• programmatically accessing an annotation (e.g. @FacesComponent)
• programmatically accessing message bundle
• writing a component handler, and access ValueExpressions/MethodExpressions
representing the values of attributes of the component
• "ugly" , but functional, approach for distinguishing between a
ValueExpression and a MethodExpression
• evaluating a ValueExpression
• invoking the method indicated via MethodExpression
• introducing JSF converters/validators handlers
• exposing the TagHandler protected methods as public methods
• using binding and converterId/validatorId attributes to instantiate a
certain converter/validator
• collecting values of attributes as ValueExpressions
• using the java.beans.Introspector API to identify the setters of a bean
• wiring attributes values with corresponding setters (literal text and
deferred value expressions)
• using Java Reflection API to invoke setters
• storing deferred value expressions and setters in a Map
• creating and using an anonymous Converter/Validator
• exploiting several features of Java Reflection API
• creating and working with a cache based on
the java.util.concurrent.ConcurrentHashMap
• storing entries in request scope
• working with Facelet scope
• collecting the values of the var and type attributes
• writing a validation handler via a tag handler "local" (via UIInput#isValid())
and "global" (via FacesContext#validationFailed()) validation
• programmatically redirecting and sending HTTP status error code
• subscribing the given Callback instance to the given component that get
invoked only in the current request when the given component system
event type is published on the given component
• collecting messages from faces messages list
• add a message in flash scope
• avoid the Faces message has been enqueued but is not displayed warning
• evaluating the given value expression as a string
• understanding the ViewExpiredException
• understanding the view restoring process
• writing a custom view handler
• creating a new view via ViewHandler#createView()
• building a view via ViewDeclarationLanguage#buildView()
• writing a custom FacesContext
• programmatically attaching/detaching a custom FacesContext
• obtaining the view associated render kit
• checking at runtime the required attributes
via TagHandler#getRequiredAttribute()
• working with TagHandler#nextHandler field
• programmatically setting an attribute of a component
• great lesson about EL API
• wrapping a ValueExpression into a MethodExpression
• developing a custom ELContext
• developing a custom ELResolver
• working with VariableMapper
• working with Facelets files
• introducing Facelet context (e.g. DefaultFaceletContext)
• introducing VariableMapper (e.g. VariableMapperWrapper)
• understanding how Facelets files are processed by JSF
• writing and setting a custom VariableMapper (DelegatingVariableMapper)
• writing a custom EnumConverter
• capturing the enum type in getAsString()
• storing/accessing the enum type in/from view map
• introducing SelectItem, SelectItemGroup, UISelectItem and UISelectItems API
• extracting all SelectItem expressed via UISelectItem and UISelectItems
• learning the algorithm expressed by a UISelectItems component that
uses the var iterator construct to generate a list of SelectItems
• working with OmniFaces, ScopedRunner
• iterating SelectItemGroup
• working with FacesContext attributes
• extracting unhandled exceptions
• handling AbortProcessingException
• locating error pages in web.xml
• programmatically creating and rendering a new view
• accessing unhandled exceptions
• turning each exception into a global FATAL faces message
• extending the PartialViewContext
• “dissecting” the partial rendering response
• understanding how a partial response is rendered via PartialResponseWriter
• writing a custom PartialResponseWriter
• altering the partial response content
• using and understanding <eval> tag
• understanding how Mojarra and MyFaces are working with partial response
• programmatically inspecting the web.xml file
• check if the web.xml security constraint has been triggered
during this AJAX request
• resetting and closing the AJAX response
• fortify your knowledge about the JSF ResourceHandler and Resource APIs
• working with the OmniFaces DefaultResourceHandler API
• collecting the context parameters from web.xml/web-fragment.xml
• replacing a resource request path
• using the Application#evaluateExpressionGet()
• introducing the OmniFaces RemappedResource
• replacing the mapping prefix/suffix of the original generated request path
• understanding the isResourceRequest() and handleResourceRequest()
• recognizing PrimeFaces dynamic resource requests
• collecting component resources by their type
• hacking RichFaces 4 component resources
• combining multiple component resources in a single one
• using server‐side cache for the combined component resources
• determining the render type for a component resource
• sequentially serving multiple resources
• modifying an existing component resource
• creating a new component resource
• understanding how <f:event> works
• adding support for new <f:event> types (preInvokeAction and postInvokeAction)
• writing a custom phase listener
• subscribing a phase listener to other events (e.g. PostValidateEvent)
• collecting components that have certain registered listener
• introducing the OmniFaces, DefaultPhaseListener
• writing an artifact that can act as an action listener or as a phase listener
• using processAction(ActionEvent) method
• getting partial executing/rendering IDs
• introducing built‐in, resetValue()
• chaining action listeners invocation
• seeing another useful Visit Tree API implementation
• introducing JSF auto‐generated IDs
• writing a custom view handler
• checking the project stage
• writing a custom ResponseWriter
• overriding ResponseWriter#cloneWithWriter()
• distinguish between "normal" IDs and "special" IDs
(e.g. view state and client window IDs)
• brief overview of other OmniFaces artifacts
• what's new in OmniFaces 3.0
1 of 46

Recommended

OmniFaces validators by
OmniFaces validatorsOmniFaces validators
OmniFaces validatorsAnghel Leonard
2.1K views34 slides
25+ Reasons to use OmniFaces in JSF applications by
25+ Reasons to use OmniFaces in JSF applications25+ Reasons to use OmniFaces in JSF applications
25+ Reasons to use OmniFaces in JSF applicationsAnghel Leonard
6.7K views33 slides
Securing JSF Applications Against the OWASP Top Ten by
Securing JSF Applications Against the OWASP Top TenSecuring JSF Applications Against the OWASP Top Ten
Securing JSF Applications Against the OWASP Top TenDavid Chandler
2.2K views66 slides
Dart for Java Developers by
Dart for Java DevelopersDart for Java Developers
Dart for Java DevelopersYakov Fain
2.1K views57 slides
Introduction to JSF by
Introduction toJSFIntroduction toJSF
Introduction to JSFSoftServe
1.3K views32 slides
Jsf by
JsfJsf
JsfShaharyar khan
1.7K views48 slides

More Related Content

What's hot

Effective JavaFX architecture with FxObjects by
Effective JavaFX architecture with FxObjectsEffective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjectsSrikanth Shenoy
2K views28 slides
Seven Versions of One Web Application by
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web ApplicationYakov Fain
2.3K views54 slides
Customizing the Presentation Model and Physical Renderer in Siebel Open UI by
Customizing the Presentation Model and Physical Renderer in Siebel Open UICustomizing the Presentation Model and Physical Renderer in Siebel Open UI
Customizing the Presentation Model and Physical Renderer in Siebel Open UITech OneStop
5K views45 slides
Siebel Open UI Debugging (Siebel Open UI Training, Part 7) by
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)Siebel Open UI Debugging (Siebel Open UI Training, Part 7)
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)Tech OneStop
1.4K views16 slides
Spring REST Request Validation by
Spring REST Request ValidationSpring REST Request Validation
Spring REST Request ValidationMohammad Sabir Khan
690 views13 slides
Test Driven Development with JavaFX by
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFXHendrik Ebbers
16.5K views64 slides

What's hot(20)

Effective JavaFX architecture with FxObjects by Srikanth Shenoy
Effective JavaFX architecture with FxObjectsEffective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjects
Srikanth Shenoy2K views
Seven Versions of One Web Application by Yakov Fain
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web Application
Yakov Fain2.3K views
Customizing the Presentation Model and Physical Renderer in Siebel Open UI by Tech OneStop
Customizing the Presentation Model and Physical Renderer in Siebel Open UICustomizing the Presentation Model and Physical Renderer in Siebel Open UI
Customizing the Presentation Model and Physical Renderer in Siebel Open UI
Tech OneStop5K views
Siebel Open UI Debugging (Siebel Open UI Training, Part 7) by Tech OneStop
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)Siebel Open UI Debugging (Siebel Open UI Training, Part 7)
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)
Tech OneStop1.4K views
Test Driven Development with JavaFX by Hendrik Ebbers
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
Hendrik Ebbers16.5K views
JSF basics by airbo
JSF basicsJSF basics
JSF basics
airbo2.6K views
RichFaces 4: Rich Ajax Components For Your JSF Applications by Max Katz
RichFaces 4: Rich Ajax Components For Your JSF ApplicationsRichFaces 4: Rich Ajax Components For Your JSF Applications
RichFaces 4: Rich Ajax Components For Your JSF Applications
Max Katz10K views
Selenium Basics Tutorial by Clever Moe
Selenium Basics TutorialSelenium Basics Tutorial
Selenium Basics Tutorial
Clever Moe41.6K views
Javascript Design Patterns by Lilia Sfaxi
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Lilia Sfaxi3.5K views

Viewers also liked

Cult Mix Athens by
Cult Mix AthensCult Mix Athens
Cult Mix AthensElli Papagrigoriou
412 views12 slides
Netbeans :) by
Netbeans :)Netbeans :)
Netbeans :)Leonardo Torres
527 views40 slides
ry_aviary-socialstrategy(ty) by
ry_aviary-socialstrategy(ty)ry_aviary-socialstrategy(ty)
ry_aviary-socialstrategy(ty)Richard A. Yumang
170 views22 slides
Ejercicios de klapp by
Ejercicios de klappEjercicios de klapp
Ejercicios de klappOmar E Acosta Z
1.1K views7 slides
¿QUE ES UN PROYECTO, CUALES SON SUS COMPONENTES Y CÓMO SE HACE EL INFORME? by
¿QUE ES UN PROYECTO, CUALES SON SUS COMPONENTES Y CÓMO SE HACE EL INFORME?¿QUE ES UN PROYECTO, CUALES SON SUS COMPONENTES Y CÓMO SE HACE EL INFORME?
¿QUE ES UN PROYECTO, CUALES SON SUS COMPONENTES Y CÓMO SE HACE EL INFORME?Leonardo Torres
261 views3 slides
Uc2907 dw by
Uc2907 dwUc2907 dw
Uc2907 dwnguyensun
383 views9 slides

Viewers also liked(15)

Similar to Mastering OmniFaces - A Problem to Solution Approach

JSF2 by
JSF2JSF2
JSF2Alex Tumanoff
2K views67 slides
Lecture 10 - Java Server Faces (JSF) by
Lecture 10 - Java Server Faces (JSF)Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)Fahad Golra
2.9K views31 slides
Java EE 8 Web Frameworks: A Look at JSF vs MVC by
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJosh Juneau
8K views43 slides
Groovy & Grails eXchange 2012 vert.x presentation by
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationStuart (Pid) Williams
3.1K views45 slides
Apache Cayenne for WO Devs by
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO DevsWO Community
3.5K views60 slides
Contextual Dependency Injection for Apachecon 2010 by
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Rohit Kelapure
2K views48 slides

Similar to Mastering OmniFaces - A Problem to Solution Approach(20)

Lecture 10 - Java Server Faces (JSF) by Fahad Golra
Lecture 10 - Java Server Faces (JSF)Lecture 10 - Java Server Faces (JSF)
Lecture 10 - Java Server Faces (JSF)
Fahad Golra2.9K views
Java EE 8 Web Frameworks: A Look at JSF vs MVC by Josh Juneau
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Josh Juneau8K views
Apache Cayenne for WO Devs by WO Community
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community3.5K views
Contextual Dependency Injection for Apachecon 2010 by Rohit Kelapure
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010
Rohit Kelapure2K views
PLAT-8 Spring Web Scripts and Spring Surf by Alfresco Software
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring Surf
Alfresco Software1.5K views
WinAppDriver Development by Jeremy Kao
WinAppDriver DevelopmentWinAppDriver Development
WinAppDriver Development
Jeremy Kao2K views
Enterprise Java Web Application Frameworks Sample Stack Implementation by Mert Çalışkan
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
Mert Çalışkan4.3K views
SharePoint Saturday The Conference DC - How the client object model saved the... by Liam Cleary [MVP]
SharePoint Saturday The Conference DC - How the client object model saved the...SharePoint Saturday The Conference DC - How the client object model saved the...
SharePoint Saturday The Conference DC - How the client object model saved the...
Liam Cleary [MVP]731 views
Mastering react with redux by Gaurav Singh
Mastering react with reduxMastering react with redux
Mastering react with redux
Gaurav Singh45 views
PLAT-7 Spring Web Scripts and Spring Surf by Alfresco Software
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring Surf
Alfresco Software6.6K views
PLAT-7 Spring Web Scripts and Spring Surf by Alfresco Software
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring Surf
Alfresco Software8.4K views
Web Technologies in Java EE 7 by Lukáš Fryč
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7
Lukáš Fryč2.2K views
Enhance existing REST APIs (e.g. Facebook Graph API) with code completion us... by johannes_fiala
Enhance existing REST APIs  (e.g. Facebook Graph API) with code completion us...Enhance existing REST APIs  (e.g. Facebook Graph API) with code completion us...
Enhance existing REST APIs (e.g. Facebook Graph API) with code completion us...
johannes_fiala2.4K views

Recently uploaded

Sprint 226 by
Sprint 226Sprint 226
Sprint 226ManageIQ
5 views18 slides
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsBushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsRa'Fat Al-Msie'deen
8 views49 slides
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J... by
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...Deltares
12 views24 slides
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...Marc Müller
40 views62 slides
Programming Field by
Programming FieldProgramming Field
Programming Fieldthehardtechnology
5 views9 slides
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko... by
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...Deltares
14 views23 slides

Recently uploaded(20)

Sprint 226 by ManageIQ
Sprint 226Sprint 226
Sprint 226
ManageIQ5 views
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by Ra'Fat Al-Msie'deen
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsBushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J... by Deltares
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
DSD-INT 2023 3D hydrodynamic modelling of microplastic transport in lakes - J...
Deltares12 views
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by Marc Müller
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
Marc Müller40 views
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko... by Deltares
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
Deltares14 views
DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft... by Deltares
DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft...DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft...
DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft...
Deltares7 views
Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable11 views
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... by Donato Onofri
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Donato Onofri860 views
DSD-INT 2023 The Danube Hazardous Substances Model - Kovacs by Deltares
DSD-INT 2023 The Danube Hazardous Substances Model - KovacsDSD-INT 2023 The Danube Hazardous Substances Model - Kovacs
DSD-INT 2023 The Danube Hazardous Substances Model - Kovacs
Deltares10 views
DSD-INT 2023 European Digital Twin Ocean and Delft3D FM - Dols by Deltares
DSD-INT 2023 European Digital Twin Ocean and Delft3D FM - DolsDSD-INT 2023 European Digital Twin Ocean and Delft3D FM - Dols
DSD-INT 2023 European Digital Twin Ocean and Delft3D FM - Dols
Deltares9 views
Ports-and-Adapters Architecture for Embedded HMI by Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
Burkhard Stubert21 views
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by Márton Kodok
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action
Márton Kodok6 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski10 views
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... by Marc Müller
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Marc Müller41 views

Mastering OmniFaces - A Problem to Solution Approach

  • 1. Anghel LeonardConstantin Alin OmniFaces is an utility library for JSF and a comprehensive compendium of programming techniques, design patterns and recipes for JSF developers.
  • 2. Inside this book, you will learn how to write robust, reusable and easy to maintain JSF code with a high level of readability, efficiency and performance. • learn how to use OmniFaces artifacts in your JSF projects • understand how OmniFaces/JSF is implemented and how it works internally • exploit the JSF API at a high level of development • explore and write JSF programming techniques and design patt erns • develop JSF reusable code • identify and fix JSF gaps, pitfalls and bugs • increase your arsenal of JSF helpers with more than 300 utilities methods • learn how to write a considerable number of JSF custom artifacts types • push your JSF skills to the limit and become a cutt ing edge developer • crumble JSF myths and misconceptions by deeply understanding the framework
  • 3. Chapter 1 - OmniFaces Components Chapter 2 - OmniFaces Validators Chapter 3 - OmniFaces Tag Handlers Chapter 4 - OmniFaces Converters Chapter 5 - OmniFaces Exception Handlers Chapter 6 - OmniFaces Exception Contexts Chapter 7 - OmniFaces Resource Handlers Chapter 8 - OmniFaces Event Listeners Chapter 9 - OmniFaces View Handlers Chapter 10 - There's More
  • 4. • registering a custom component for listening PostRestoreStateEvent • programmatically extracting the value of an attribute • searching components using relative‐up/down search algorithm • collect the value of the label attribute for the given UI component • setting an attribute value as a literal or as a value expression
  • 5. • instructing an UIComponent to support a JSF converter • sample of extending the ValueHolder interface (ParamHolder) • having a quick overview of how to use StateHelper class • introducing static vs. dynamic converters • temporarily replacing the default output response (ResponseWriter)
  • 6. • working with attributes of type var • suppress the invocation of setValueExpression() for an attribute • replacing/restoring the ResponseWriter in the rendering process • carrying an artifact via the FacesContext attributes map • putting an artifact in the request map (scope)
  • 7. • programmatically indicating the renderer of a component • indicating that a component will render its children also • understanding the triplet: encodeBegin(), encodeChildren(), encodeEnd() • programmatically collecting the available messages – FacesMessages • discovering the OmniFaces utility, findComponentsInChildren() • storing/removing something in/from request scope (request map) • replacing/restoring something from/in request scope (request map) • "postponing"/triggering the rendering of a component • programmatically generating the markup of a HTML table/list
  • 8. • working with the @ListenerFor annotation • rendering the <script/> element • determining if the current request is/isn t an AJAX requestʹ • determining if the value of the render attribute is @all • programmatically subscribe to view events (e.g. PreRenderViewEvent) • using the OmniPartialViewContext for executing the given scripts on completion of the current AJAX response
  • 9. • marking a resource as rendered • programmatically creating a Resource • rendering the <script/> element when a resource exist • rendering the <script/> element when a resource does not exist
  • 10. • working with JSF VisitTree API • access, from JS, the HTML markup via the client IDs provided by JSF
  • 11. • transforming a stateful component into a stateless component • suppressing decoding and validation at postback requests • suppressing the built‐in required validator • using the name attribute when the label attribute is absent • working with the OmniFaces utility, MapWrapper
  • 12. • working with several OmniFaces utility methods • writing a custom FacesContext, Application and ViewHandler • working with ViewHandler#getActionURL() • encoding URLs • programmatically control Process Validations phase (via processValidators()) and Update Model Values phase (via processUpdates()) • subscribing with a Callback to after Restore View phase • a good example for understanding the JSF lifecycle
  • 13. • JSF post‐processing tips • subscribing with Callbacks to view/phase events • working with BufferedHttpServletResponse • introducing TagHandlers • working with VariableMapper • overriding UIComponent#isVisitable()
  • 14. • programmatically loading the JSF AJAX library • writing a custom UICommand • extracting all UIParameters nested in a certain component • validating if a component has a parent of a certain type • resolve the given space separated collection of relative client IDs to absolute client IDs • creating and queuing an ActionEvent • adding the autorun feature
  • 15. • introducing “facelet scope” • passing FaceletContext to a custom UIComponent • storing a ValueExpression in the “facelet scope” • storing a UIComponent in request scope • subscribing to PreRenderViewEvent and PostRestoreStateEvent • writing a custom ValueExpression • working with ReadOnlyValueExpression • writing a functional Callback • finding a component in the component tree by client ID
  • 16. • working with OmniFaces, validateHasNoChildren() utility method • obtaining the environment‐specific object instance for the current request/response • building a buffered response via OmniFaces, BufferedHttpServletResponse using the Servlets API RequestDispatcher to includes the content of a resource
  • 17. • understanding how JSF processes images • working with JSF resource handlers • writing a cacheable dynamic resource • working with images request path • understanding how “last modified” works • obtaining/determining image content type • obtaining the data URI from an image • parsing/evaluating a ValueExpression and store • converting a ValueExpression into a request path eligible for Reflection API • parsing a request path and invoking a method using Java Reflection API • testing the presence of an annotation on a class • converting strings to objects using converters registered on given types • converting objects to strings using converters registered on given types
  • 18. • extending ViewParam • processing request query parameters • understanding decode() method goal • suppressing validations and data model updates • writing a custom PhaseListener • learning about quick succession of writings • turn off/on the original response writer
  • 19. • moving components in the component tree • moving facets and behaviors • understanding how behaviors works in JSF • implementing ClientBehaviorHolder • subscribing to PreRenderViewEvent, and PostAddToViewEvent
  • 20. • exploring several Tree use cases • controlling the processDecodes(), processValidators(), processUpdates() and the encodeChildren() from a single place (TreeFamily) • using a "bunch" of OmniFaces utilities which are very handy in day by day development • following the JSF flow in a recursive implementation • working with the "special" attributes, var and varNode • exploring how the events are queued and broadcasted
  • 21. • introducing javax.faces.FACELETS_SKIP_COMMENTS • understanding the escape attribute role • defining a Java reserved word as an enum item
  • 22. • introducing Bean Validation • obtaining the default message interpolator • customizing the default message interpolator
  • 23. • writing a template validator • writing a template converter • check if a component supports validators/converters (is an instance of EditableValueHolder) • programmatically obtain the model value of a component • explicitly invoke the converter getAsString() method
  • 24. • implement a custom validator • programmatically check a component type • programmatically locate a message bundle and access its keys
  • 25. • implement a validator as a TagHander • what s a JSFʹ new component in the component tree • get the value of an attribute as a ValueExpression to be carried around and evaluated later in the lifecycle without needing the Facelet context • postpone a task before/after a JSF lifecycle phase of the current request • get the closest parent of the given parent type • write a SystemEventListener for PreValidateEvent and PostValidateEvent • fired by UIInputs that have attached a BeanValidator • finding a certain validator in the list of validators of a component • programmatically point/replace/restore the BeanValidator validation groups • use OmniFaces Copier API for copying objects • traverse a form children and extract the ValueReference of each EditableValueHolder for the specified base
  • 26. • implementing a custom validator as a TagHandler that is registered as a listener for ValueChangeEvent • ValueChangeEvent internal overview • JSF VisitTree implementation sample ‐ visit a JSF table rows (UIData iteration) • tips for collecting the values of an UIInput component in an UIData component • signaling invalid values
  • 27. • "intercepting" Apply Request Values phase via processDecodes() method • "intercepting" Process Validators phase via processValidators() method • "intercepting" Update Model phase via processUpdates() method • collecting inputs (and their values) from a form • marking invalidation at component/context level • associating the message bundle keys with components COMPONENT_TYPEs • programmatically accessing an annotation (e.g. @FacesComponent) • programmatically accessing message bundle • writing a component handler, and access ValueExpressions/MethodExpressions representing the values of attributes of the component • "ugly" , but functional, approach for distinguishing between a ValueExpression and a MethodExpression • evaluating a ValueExpression • invoking the method indicated via MethodExpression
  • 28. • introducing JSF converters/validators handlers • exposing the TagHandler protected methods as public methods • using binding and converterId/validatorId attributes to instantiate a certain converter/validator • collecting values of attributes as ValueExpressions • using the java.beans.Introspector API to identify the setters of a bean • wiring attributes values with corresponding setters (literal text and deferred value expressions) • using Java Reflection API to invoke setters • storing deferred value expressions and setters in a Map • creating and using an anonymous Converter/Validator
  • 29. • exploiting several features of Java Reflection API • creating and working with a cache based on the java.util.concurrent.ConcurrentHashMap • storing entries in request scope • working with Facelet scope • collecting the values of the var and type attributes
  • 30. • writing a validation handler via a tag handler "local" (via UIInput#isValid()) and "global" (via FacesContext#validationFailed()) validation • programmatically redirecting and sending HTTP status error code • subscribing the given Callback instance to the given component that get invoked only in the current request when the given component system event type is published on the given component • collecting messages from faces messages list • add a message in flash scope • avoid the Faces message has been enqueued but is not displayed warning • evaluating the given value expression as a string
  • 31. • understanding the ViewExpiredException • understanding the view restoring process • writing a custom view handler • creating a new view via ViewHandler#createView() • building a view via ViewDeclarationLanguage#buildView() • writing a custom FacesContext • programmatically attaching/detaching a custom FacesContext • obtaining the view associated render kit
  • 32. • checking at runtime the required attributes via TagHandler#getRequiredAttribute() • working with TagHandler#nextHandler field • programmatically setting an attribute of a component
  • 33. • great lesson about EL API • wrapping a ValueExpression into a MethodExpression • developing a custom ELContext • developing a custom ELResolver • working with VariableMapper
  • 34. • working with Facelets files • introducing Facelet context (e.g. DefaultFaceletContext) • introducing VariableMapper (e.g. VariableMapperWrapper) • understanding how Facelets files are processed by JSF • writing and setting a custom VariableMapper (DelegatingVariableMapper)
  • 35. • writing a custom EnumConverter • capturing the enum type in getAsString() • storing/accessing the enum type in/from view map
  • 36. • introducing SelectItem, SelectItemGroup, UISelectItem and UISelectItems API • extracting all SelectItem expressed via UISelectItem and UISelectItems • learning the algorithm expressed by a UISelectItems component that uses the var iterator construct to generate a list of SelectItems • working with OmniFaces, ScopedRunner • iterating SelectItemGroup • working with FacesContext attributes
  • 37. • extracting unhandled exceptions • handling AbortProcessingException • locating error pages in web.xml • programmatically creating and rendering a new view
  • 38. • accessing unhandled exceptions • turning each exception into a global FATAL faces message
  • 39. • extending the PartialViewContext • “dissecting” the partial rendering response • understanding how a partial response is rendered via PartialResponseWriter • writing a custom PartialResponseWriter • altering the partial response content • using and understanding <eval> tag • understanding how Mojarra and MyFaces are working with partial response • programmatically inspecting the web.xml file • check if the web.xml security constraint has been triggered during this AJAX request • resetting and closing the AJAX response
  • 40. • fortify your knowledge about the JSF ResourceHandler and Resource APIs • working with the OmniFaces DefaultResourceHandler API • collecting the context parameters from web.xml/web-fragment.xml • replacing a resource request path • using the Application#evaluateExpressionGet() • introducing the OmniFaces RemappedResource
  • 41. • replacing the mapping prefix/suffix of the original generated request path • understanding the isResourceRequest() and handleResourceRequest() • recognizing PrimeFaces dynamic resource requests
  • 42. • collecting component resources by their type • hacking RichFaces 4 component resources • combining multiple component resources in a single one • using server‐side cache for the combined component resources • determining the render type for a component resource • sequentially serving multiple resources • modifying an existing component resource • creating a new component resource
  • 43. • understanding how <f:event> works • adding support for new <f:event> types (preInvokeAction and postInvokeAction) • writing a custom phase listener • subscribing a phase listener to other events (e.g. PostValidateEvent) • collecting components that have certain registered listener • introducing the OmniFaces, DefaultPhaseListener
  • 44. • writing an artifact that can act as an action listener or as a phase listener • using processAction(ActionEvent) method • getting partial executing/rendering IDs • introducing built‐in, resetValue() • chaining action listeners invocation • seeing another useful Visit Tree API implementation
  • 45. • introducing JSF auto‐generated IDs • writing a custom view handler • checking the project stage • writing a custom ResponseWriter • overriding ResponseWriter#cloneWithWriter() • distinguish between "normal" IDs and "special" IDs (e.g. view state and client window IDs)
  • 46. • brief overview of other OmniFaces artifacts • what's new in OmniFaces 3.0