If you can try something like this to get a fresh instance of the desired page.

@InjectPage("NameOfMyPage")
public abstract MyPage getMyPage();

With the instance acquired by this method you can do something like this 
(pseudo code):

IPage page = getMyPage();
....
Use the page instance to get the validation delegate of it and register your 
error against it.
....
getRequestCylce.activate( page );


Mit lieben Grüßen aus dem eWerk

  |  Holger Stolzenberg
  |  Softwareentwickler
  |
  |  Geschäftsführer: 
  |  Frank Richter, Erik Wende, Hendrik Schubert
  |
  |  eWerk IT GmbH
  |  Markt 16
  |  Leipzig 04109
  |  http://www.ewerk.com
  |  HRB 9065, AG Leipzig
  |  Hauptniederlassung Leipzig
  |
  |  fon +49.341.4 26 49-0
  |  fax +49.341.4 26 49-88
  |  mailto:[EMAIL PROTECTED]
  |
  |  Support:
  |  fon 0700 CALLME24 (0700 22556324)
  |  fax 0700 CALLME24 (0700 22556324)
  |
  | Auskünfte und Angebote per Mail
  | sind freibleibend und unverbindlich. 

-----Ursprüngliche Nachricht-----
Von: Kolesnikov, Alexander GNI [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 22. März 2007 13:32
An: Tapestry users
Betreff: [T4] PageRedirectException

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 
==============================================================================

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to