Hi,
i have the following problem using paging dataproviders. If the
PagingDataProvider.size() throws an Exception, the click servlet doesn't
redirect to the configured error page. It looks like it sees the exception
as some sort of parsing error (velocity?). It only redirects the exceptions
thrown by the page lifecycle methods. I have put together a simple test
case, like this:
a.- IndexPage.java
public class IndexPage extends Page {
@Bindable
public Table table = new Table("table");
public IndexPage() {
table.setDataProvider(new PagingDataProvider() {
public int size() {
if (Math.random() > 0.5d) { //to simulate an exception
throw new RuntimeException(); // (*1)
}
return 1;
}
public Iterable getData() {
// TODO Auto-generated method stub
ArrayList arrayList = new ArrayList();
arrayList.add(new Object());
return arrayList;
}
});
table.addColumn(new Column("hashCode"));
}
@Override
public void onRender() {
if (Math.random() > 0.5d) {
throw new RuntimeException(); //(*2)
}
super.onRender();
}
}
b.- click.xml
<click-app charset="UTF-8">
<pages package="xyz" autobinding="annotation">
<page path="/click/error.htm" classname="TheErrorPage" />
</pages>
<mode value="debug" />
</click-app>
c.- TheErrorPage.java
public class TheErrorPage extends ErrorPage {
}
d.- /click/error.htm
"this is an error page"
e.- index.htm
Hello, index page here...now with the table...
$table
--------------------------
When this code runs, and throws the RuntimeException() in (*1), the rendered
page is the index page, but the table rendering prints a error box. But when
the random value is lower than 0.5, the onRender is executed, and the
RuntimeException() (*2) it throws, gets the click servlet to redirect to the
error page.
Is there any way to fix this?
--
Manuel Chinea.