PDA

View Full Version : Handling Exception while using AjaxUrlBasedViewResolver & Spring.AjaxEventDecoration



scranjith
Mar 9th, 2012, 04:52 PM
Hi,
I am using Spring MVC, AjaxUrlBasedViewResolver, Spring-js (Spring.AjaxEventDecoration) is my application.
I have also used InternalResourceViewResolver in few screens.
I need to configure a centralized Exception Resolver.

<bean class="org.springframework.web.servlet.handler.SimpleMapp ingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="com.nbcu.common.exception.AddressBookException">error</prop>
<prop key="java.lang.Exception">error</prop>
</props>
</property>
</bean>
The above config works fine for InternalResourceViewResolver.
But while using AjaxUrlBasedViewResolver the error page rendering is not as desirable (the exception message overlaps the existing tiles html page).
Please suggest a better solution to handle exception while using AjaxUrlBasedViewResolver.

dr_pompeii
Mar 10th, 2012, 06:52 PM
But while using AjaxUrlBasedViewResolver the error page rendering is not as desirable (the exception message overlaps the existing tiles html page)
Could you show your JSP file content? Little confuse your problem

scranjith
Mar 12th, 2012, 10:54 AM
Dr_pompeii,
thanks your response,
I am looking for a general solution for the above scenario. What is the best way to handle exception (in case of tiles and ajax calls) using spring exception resolver and display a message to the user?
Couple of options that I have thought thro'

1) Display the error message in the tiles section from which the request originated.
Since the general exception resolver wouldn't know the tile-view name and the fragment name, it can not route the exception to the correct fragment.
I guess we can write some custom code to figure out the tile-view name and fragment name.
But I want to know if there is a solution already available.

2) I can set the exception message to the BindingResult and display it @ the top of the section.
Still I am not sure how to achieve this :).

Appreciate you help.

scranjith
Mar 14th, 2012, 09:13 AM
Can anyone throw in some ideas.
It will be of great help.

Thanks.