• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Building Exception page using tiles

 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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"/>

</action>

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??
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jignesh,

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 ]
 
Our first order of business must be this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic