i modified the examples DataTablePage with the following and it worked just fine, not sure what its not working for you:
add(new DefaultDataTable("table", columns, new SortableDataProvider() {
public Iterator iterator(int first, int count)
{
throw new RestartResponseException(new GridViewPage());
}
public int size()
{
throw new RestartResponseException(new GridViewPage());
}
public IModel model(Object object)
{
// TODO Auto-generated method stub
return null;
}
}, 8));
-Igor
Are we not expected to go to the database when the "iterate(first, count)" method is called? That's when the database tells me (through an SQLException) that the table hasn't been created yet.
I am beginning to wonder about assumed invariants that I did not take into consideration in my current design. When the user changes some query parameters, then the next page refresh should replace the data in the table based on the new query. I've assumed that I can handle this merely by changing the results returned by IDataprovider.iterate(first, count), but now I'm beginning to wonder.
A change in the query changes the result of IDataProvider.size(). If DataTable does not deal will with changing data sizes, maybe I have to respond to a change in SQL query at a higher level – not merely to have the IDataProvider reflect the changes, but to replace the whole table. What do you think? Anyway, here is the result I got. Do you need the log file? (Or do I just need to back up and realize that the DataTable is not quite as flexible as I'd assumed.)
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
wicket.WicketRuntimeException: Internal Error: Could not render error page class wicket.markup.html.pages.InternalErrorPage
wicket.request.compound.DefaultExceptionResponseStrategy.respond(DefaultExceptionResponseStrategy.java :106)
wicket.request.compound.AbstractCompoundRequestCycleProcessor.respond (AbstractCompoundRequestCycleProcessor.java:76)
wicket.RequestCycle.step (RequestCycle.java:971)
wicket.RequestCycle.steps(RequestCycle.java :1005)
wicket.RequestCycle.request(RequestCycle.java:451)
wicket.protocol.http.WicketServlet.doGet(WicketServlet.java :212)
wicket.protocol.http.WicketServlet.doPost(WicketServlet.java :250)
javax.servlet.http.HttpServlet.service(HttpServlet.java :709)
javax.servlet.http.HttpServlet.service(HttpServlet.java :802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Igor VaynbergSent: Friday, March 24, 2006 11:06 AM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] DataTable and IDataProvider question
how did it crash? what was the output?
another thing is cant you try this before the datatable is even rendering? why do the check so late in the game?
-Igor
On 3/24/06, Frank Silbermann < [EMAIL PROTECTED]> wrote:
I'm using 1.2 B2
-----Original Message-----
From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Igor VaynbergSent: Friday, March 24, 2006 10:41 AM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] DataTable and IDataProvider question
request cycle. are you using 1.2 head?
-IgorOn 3/24/06, Frank Silbermann < [EMAIL PROTECTED] > wrote:
I did that, and it crashed. Who is supposed to catch the RestartResponseException to restart the response?
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Igor Vaynberg
Sent: Friday, March 24, 2006 10:13 AM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] DataTable and IDataProvider question
try throwing RestartResponseException.
-IgorOn 3/24/06, Frank Silbermann < [EMAIL PROTECTED] > wrote:
I am working with a database that is kind of strange. Someone provides a new table with each day's data. Thus, the database can cause an SQLException as a normal result for the use case where the user requests data that hasn't been produced yet.
When my "Iterator IDataprovider.iterate(int first, int count)" method is called and I go to the database, I would like to handle the SQLException to call "void Component.setResponsePage( Class.responsePage)" to tell the user what has happened, passing in PageParameters to enable the user to continue.
It seems that DataTable does not like me jumping out of the "iterate(first,count)" method like that. It tries to set the ResponsePage to the Wicket error page, which causes a serious failure saying that one cannot set the ResponsePage twice.
What are my options for solving this problem?
Is it simply a matter of making my "iterate(first,count) return an empty iterator to satisfy the DataTable caller before my "setResponsePage()" can take effect?
Here is the relevant section from the Tomcat logfile:
Mar 24, 2006 8:11:03 AM org.apache.catalina.core.ApplicationContext log
INFO: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: http://jakarta.apache.org]]
Mar 24, 2006 8:11:03 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Mar 24, 2006 8:11:03 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Mar 24, 2006 8:11:10 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Mar 24, 2006 8:11:10 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Mar 24, 2006 8:11:20 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet MEM_Application threw exception
wicket.WicketRuntimeException: Internal Error: Could not render error page class wicket.markup.html.pages.InternalErrorPage
at wicket.request.compound.DefaultExceptionResponseStrategy.respond(DefaultExceptionResponseStrategy.java:106)
at wicket.request.compound.AbstractCompoundRequestCycleProcessor.respond(AbstractCompoundRequestCycleProcessor.java:76)
at wicket.RequestCycle.step(RequestCycle.java:971)
at wicket.RequestCycle.steps(RequestCycle.java:1005)
at wicket.RequestCycle.request(RequestCycle.java:451)
at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:212)
at wicket.protocol.http.WicketServlet.doPost(WicketServlet.java:250)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: wicket.WicketRuntimeException: Already redirecting to '/MEMSpssWebModule/mem?wicket:interface=:0:1:'. Cannot redirect more than once
at wicket.protocol.http.BufferedWebResponse.redirect(BufferedWebResponse.java:88)
at wicket.protocol.http.WebRequestCycle.redirectTo(WebRequestCycle.java:205)
at wicket.request.target.component.PageRequestTarget.respond(PageRequestTarget.java:60)
at wicket.request.compound.DefaultResponseStrategy.respond(DefaultResponseStrategy.java:49)
at wicket.request.compound.AbstractCompoundRequestCycleProcessor.respond(AbstractCompoundRequestCycleProcessor.java:66)
at wicket.RequestCycle.respond(RequestCycle.java:877)
at wicket.RequestCycle.step(RequestCycle.java:946)
... 20 more
Mar 24, 2006 8:11:28 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeReplaced('org.apache.catalina.WELCOME_FILES', '[Ljava.lang.String;@13ac14d')
Mar 24, 2006 8:11:28 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeReplaced('org.apache.catalina.WELCOME_FILES', '[Ljava.lang.String;@68d505')
Mar 24, 2006 8:11:28 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeReplaced('org.apache.catalina.WELCOME_FILES', '[Ljava.lang.String;@7973e4')
Mar 24, 2006 8:11:28 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Mar 24, 2006 8:11:28 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Mar 24, 2006 8:11:28 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeReplaced('org.apache.catalina.WELCOME_FILES', '[Ljava.lang.String;@4a5320')
Mar 24, 2006 8:11:28 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeReplaced('org.apache.catalina.WELCOME_FILES', '[Ljava.lang.String;@1978622')
Mar 24, 2006 8:11:28 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeReplaced('org.apache.catalina.WELCOME_FILES', '[Ljava.lang.String;@e73783')
Mar 24, 2006 8:11:28 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Mar 24, 2006 8:11:28 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()