Author: tandraschko
Date: Sat Feb 15 19:54:53 2014
New Revision: 1568671
URL: http://svn.apache.org/r1568671
Log:
documentation for JSF exception control
Modified:
deltaspike/site/trunk/content/jsf.mdtext
Modified: deltaspike/site/trunk/content/jsf.mdtext
URL:
http://svn.apache.org/viewvc/deltaspike/site/trunk/content/jsf.mdtext?rev=1568671&r1=1568670&r2=1568671&view=diff
==============================================================================
--- deltaspike/site/trunk/content/jsf.mdtext (original)
+++ deltaspike/site/trunk/content/jsf.mdtext Sat Feb 15 19:54:53 2014
@@ -1254,6 +1254,82 @@ Example:
}
}
+#Intergration with Exception Control
+
+Whenever a unhandled exception occurs within the JSF lifecycle, our JSF
ExceptionHandler provides a integration to the DeltaSpike Exception Control.
+
+## Examples
+
+### Basic
+
+ :::java
+ @ExceptionHandler
+ public class ApplicationExceptionHandler
+ {
+ public void handleELException(@Handles ExceptionEvent<ELException>
event)
+ {
+ // ...
+
+ event.handled();
+ }
+ }
+
+### Redirect
+
+
+ :::java
+ @ExceptionHandler
+ public class ApplicationExceptionHandler
+ {
+ public void handleELException(@Handles ExceptionEvent<ELException>
event)
+ {
+
FacesContext.getCurrentInstance().getApplication().getNavigationHandler().handleNavigation(...);
// or ExternalContext etc.
+
+ // required - "stops" the JSF lifecycle
+ FacesContext.getCurrentInstance().setResponseComplete();
+
+ event.handled();
+ }
+ }
+
+## Using a custom qualifier for JSF Exceptions
+
+In some cases, it's required to differentiate exceptions from JSF and normal
exceptions.
+This is possible via a CDI qualifier:
+
+ :::java
+ @Target({ ElementType.TYPE, ElementType.PARAMETER })
+ @Retention(RetentionPolicy.RUNTIME)
+ @Documented
+ @Qualifier
+ public @interface Jsf
+ {
+ }
+
+ @Specializes
+ public class MyJsfModuleConfig extends JsfModuleConfig
+ {
+ public Class<? extends Annotation> getExceptionQualifier()
+ {
+ return Jsf.class;
+ }
+ }
+
+ @ExceptionHandler
+ public class ApplicationExceptionHandler
+ {
+ public void handleELException(@Handles @JsfExceptionEvent<ELException>
event)
+ {
+
FacesContext.getCurrentInstance().getApplication().getNavigationHandler().handleNavigation(...);
// or ExternalContext etc.
+
+ // required - "stops" the JSF lifecycle
+ FacesContext.getCurrentInstance().setResponseComplete();
+
+ event.handled();
+ }
+ }
+
+
# Support of EAR deployments
Before using features described by this page, please ensure that you are aware
of [DELTASPIKE-335](https://issues.apache.org/jira/browse/DELTASPIKE-335) and
the corresponding impact.