I am using contrib:Table to display the results of a search. If a search returns zero results, I want to treat this as an error and to show the search form again with this error in the same way as if it was a faulty user input validation.
It seems to me that a good solution to throw a PageRedirectException at the moment when the Table component receives a source with 0 records in it. I have tried to do this in the method that provides the model for the page, like so: public IBasicTableModel getModel() { // some code to prepare the model if (model.getRowCount() == 0) { throw new PageRedirectException("Search"); } return model; } But in this case the PageRedirectException was not caught by Tapestry but propagated. Another attempt was to override the renderComponent() method of the Table component, like so: protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) { if (getSource().getRowCount() == 0) { throw new PageRedirectException("Search"); } super.renderComponent(writer, cycle); } This seems to work when redirecting to a different page. However, I want to redirect to the same page because the search form and the table of results are simply two views of the same page, shown or hidden by If components as needed. And when I am trying to redirect to the same page, again, PageRedirectException is not caught but propagated, and the application crashes. Does anybody know, why PageRedirectException is sometimes caught but at other times propagated and what to do about this? Or maybe you can see a different solution for my problem? Thanks, Alex ------------------------------------------------------------------------------ CONFIDENTIALITY NOTICE: If you have received this email in error, please immediately notify the sender by e-mail at the address shown. This email transmission may contain confidential information. This information is intended only for the use of the individual(s) or entity to whom it is intended even if addressed incorrectly. Please delete it from your files if you are not the intended recipient. Thank you for your compliance. Copyright 2007 CIGNA ==============================================================================