Tables in Tab Sets
L.S.
I have a page which contains a tab set with four tabs (home, opening hours, training and diary). I want three of the four tabs to display data from a database in a table. The tab set works fine but as soon as a add a table to a tab's layoutPanel and bind it to a parameterised query I get an HTTP status 500 error (the server encountered an internal error() that prevented it form fullfilling this request) when I run the project.
I know this error is caused by the fact that the parameter in the query is not set when I first access the page; they are set in the tab's _action event handler when the user clicks the tab.
I tried to solve the problem using virtual forms, but you can't configure a virtual form on a table component. I presume I need to add code to the page's prerender method telling it to ignore the tables when I first access the page, but I haven't got a clue how to do this.
Does anyone know how to solve this problem?
Thanks,
Annet.
[1007 byte] By [
JagXa] at [2007-11-27 11:02:28]

# 1
I use tab sets extensively in the web app I'm developing. I also use bound tables on multiple tabs. Some of my queries are parameterized too. Here's how I handled the situation.
In the prerender method, I check to see if the parameter is "defined".
Usually, the parameter value is based on a user's selection from a previous page. I save the value in a session bean before navigating to the page containing the tab set.
If a parameter is defined, I pass that value to the row set and execute the query.
If the parameter is not defined, I pass a value to the row set that I know will return a null set.
Typically, the parameter refers to a primary or foreign key. All my key values are positive numbers. If the parameter is not defined, I just use -1.
# 2
Thanks for your reply John,
But, the page contains three table components, each with their own rowSet and dataProvider, isn't it a bit awkward to set the parameter three times only because otherwise the page can't be rendered? Doesn't that generate a lot of unnecessary database traffic?
Isn't their really a way to just discard the tables and their rowSets and dataProviders?
Thanks,
Annet.
JagXa at 2007-7-29 12:43:37 >

# 3
Step 1
Set the table's render property to false in prerender if there's no parameter value to set.
My gut feeling is that this won't do the trick by itself.
Step 2
A data provider's cached row set is specified in the page's init method. You could override that in the prerender method. What if you set the data provider's cachedRowSet property to null there.
I'm not sure that will work either because the table's columns are bound to the data provider. So if the data provider were null, there wouldn't be anything for the columns to bind to.
The question is, if a table isn't rendered, are its bindings ignored when the page is rendered?
Another question is will a data provider with a null row set throw an exception?
As for your comment about excess database traffic, if the parameter is defined, you'll get a non-empty result set, which is what you want. If the parameter is not defined and you set the parameter such that the result set will be empty, database traffic will be minimal. The database server will still have to execute the query though.