faces config.xml
Code:
<managed-bean>
<description>Bean de gestion des Référentiels</description>
<managed-bean-name>myBean</managed-bean-name>
<managed-bean-class>
mypackage.myBean
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>service</property-name>
<value>#{myServiceProxy}</value>
</managed-property>
<managed-property>
<property-name>myId</property-name>
<value>#{param.myID}</value>
</managed-property>
</managed-bean>
InterceptedExceptionAdvice.java
Code:
public class InterceptExceptionAdvice implements ThrowsAdvice {
ResourceBundle bundle = ResourceBundle
.getBundle("mypackage.Exception");
String text = null;
public void afterThrowing(HibernateException he) throws TechnicalException {
text = bundle.getString(he.getMessage().toString());
FacesContext.getCurrentInstance().addMessage(
"TechnicalException",
new FacesMessage(FacesMessage.SEVERITY_ERROR, "TechnicalException", text));
throw new TechnicalException(he);
}
Applicationcontext.xml
Code:
<bean id="RuntimeAdvice" class="mypackage.InterceptExceptionAdvice"></bean>
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<value>myServiceProxy</value>
</property>
<property name="interceptorNames">
<list>
<value>RuntimeAdvice</value>
</list>
</property>
</bean>