In my first struts application i have made the web pages using the tiles framework.This is my tiles-def.xml
The portion in the bold i have added recently.
This is my search action mapping in the struts-config.xml
<action path = "/search" type = "classname" name = "formname" scope = "request" validate = "true" input = "search.page" />
<!--Action specific exception handler--> <exception type = "exception class's Fully qualified name" key = "error.NoResultsFoundException" path = "/exception.jsp"/>
In the usual way i can define an exception.jsp page with html tags, its title,its body.But i want to make it using tiles so that the header ,footer pages remain same & the only thing that remains to be changed is the body content of the page..
So how can i achieve the thing mentioned above in my current scenario??
The Art Of Life Is To Know When To Be Useless And When To Be Useful - CHUANG TZU
One possible way to do this would be to define an action that forwards to exception.page. Then in your global exception definition, specify: path = "/myAction.do" /> where myAction is the action you've defined that forwards to exception.page.
But Merrill , in that case would this not happen :if any other action apart from my SearchAction throws an exception then for that exception teh user would also forwarded to the same page as that for my SearchAction as its mentioned in the <global-exceptions> tag ???
I want to customize my exception page with specific messages.If you don't mind please provide some sample code snippet..
Joined: Feb 15, 2005
The whole point of a global exception is to provide a page that gets displayed if a specific exception is thrown regardless of where that exception is thrown.
If you want an error page only for one specific action, then you would need to define a local forward for that action (SearchAction). You would then put a try/catch block in that action and catch the specific exception, returning that forward if the exception is thrown.
If you want the same error page but with different messages on the page, the thing to do is define a global forward to that page. You would still catch exceptions in your Action classes with try/catch blocks, but you could put whatever message you want in the ActionMessages object before forwarding to the page. You could then have the error page display whatever is in the ActionMessages object.
For some examples, see the heading "Displaying Messages" in this link. [ June 26, 2006: Message edited by: Merrill Higginson ]