> -----Original Message----- > From: bansi [mailto:[EMAIL PROTECTED] > Sent: Friday, June 01, 2007 1:29 PM > To: [email protected] > Subject: Exception Handling using JSF/MyFaces and Spring > > > I am using JSF MyFaces, Spring, Hibernate . > Any pointers/suggestions on how to modify below code to display > user-friendly messages onto browser incase an exception occured in JSF > Backing Bean or Spring Bean will be highly appreciated
Your code looks fine -- if you want the user to see a message on the same page, the simplest thing to do is just add an error message to the FacesContext and return null rather than throwing a FacesException. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Kito D. Mann - Author, JavaServer Faces in Action http://www.virtua.com - JSF/Java EE consulting, training, and mentoring http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info * Sign up for the JSF Central newsletter! http://oi.vresp.com/?fid=ac048d0e17 * > > JSF Backing Bean: > > public List getDeviceTypeList(){ > try { > deviceTypes = deviceTypeManager.getDeviceTypeList(); // method call to > Spring Bean > return deviceTypeSelectItems; > } catch (Exception e) { > String msg = "Could not retrieve DeviceType List " + e.toString(); > this.logger.error(msg); > throw new FacesException(msg); > } > } > > Spring Bean: > > public List getDeviceTypeList() throws BaseException{ > List deviceTypeList = null; > try{ > deviceTypeList = deviceTypeDao.findByNamedQuery("findDeviceTypes"); // > database call > } catch (NullPointerException ne) { > String msg = "Could not retrieve data from Database " + > ne.getMessage(); > this.logger.error(msg, ne); > } catch (Exception e) { > String msg = "Could not retrieve data from Database " + e.toString(); > this.logger.error(msg, e); > throw new BaseException(msg, e); > } > return deviceTypeList; > } > > Is it true that Spring advocates against having signature of business > methods throws exception ??? > For example in my case it is public List getDeviceTypeList() throws > BaseException > > Regards > Bansi > > > > -- > View this message in context: http://www.nabble.com/Exception-Handling- > using-JSF-MyFaces-and-Spring-tf3853562.html#a10917207 > Sent from the MyFaces - Users mailing list archive at Nabble.com.

