You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christopher Corde <cc...@yahoo.com> on 2004/08/19 21:52:00 UTC
Proper method of initializing table source
Hey,
I have a table component, where I was originally
initializing the source list in a dedicated method
call before activating the page. For example:
ClientPage page = (ClientPage)
cycle.getPage("ClientPage");
page.loadClientList();
cycle.activate(page);
However, the issue I had was that when two users
browsed the table, one's list would overwrite the
others (after sorting, searching, etc). I attempted to
alleviate this by making the source list a persistent
property, like this:
ClientPage page = (ClientPage)
cycle.getPage("ClientPage");
List clientList = initializeListFromDatabase();
page.setProperty("clientList", clientList);
cycle.activate(page);
When I do that, I get this error message:
org.apache.tapestry.ApplicationRuntimeException
Either the tableModel parameter or both source and
columns parameters must be specified by component
ClientPage/table.tableView
What is the proper method of defining the table source
so that multiple users can use the page at the same
time?
Thanks,
Chris
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Proper method of initializing table source
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Aug 19, 2004, at 3:52 PM, Christopher Corde wrote:
> I have a table component, where I was originally
> initializing the source list in a dedicated method
> call before activating the page. For example:
>
> ClientPage page = (ClientPage)
> cycle.getPage("ClientPage");
> page.loadClientList();
> cycle.activate(page);
>
> However, the issue I had was that when two users
> browsed the table, one's list would overwrite the
> others (after sorting, searching, etc).
I presume you were populating instance variables in loadClientList.
Right?
You have to be quite careful with instance variables. They should be
cleared in an overloaded initialize() method to ensure another user
does not get those values. I suspect just doing that initialize()
would solve the issue for you.
> I attempted to
> alleviate this by making the source list a persistent
> property, like this:
>
> ClientPage page = (ClientPage)
> cycle.getPage("ClientPage");
> List clientList = initializeListFromDatabase();
> page.setProperty("clientList", clientList);
> cycle.activate(page);
>
> When I do that, I get this error message:
>
> org.apache.tapestry.ApplicationRuntimeException
> Either the tableModel parameter or both source and
> columns parameters must be specified by component
> ClientPage/table.tableView
I prefer to invert the situation from what you're doing. I have the
next page do the actual DB lookup, whereas you're doing it from the
first page.
You've left out some details here. You're binding "clientList"
directly to a contrib:Table source parameter? That should be ok on the
first render, but you'd probably get an error if you sorted or paged
the table. You have to be sure the data is available at sorting/paging
time too (probably not the issue you're encountering though).
> What is the proper method of defining the table source
> so that multiple users can use the page at the same
> time?
Your question is actually two separate questions or more. Instance
variables in page classes need to be cleared in initialize() [this is a
confusing name, we all know, but it is the method invoked when Tapestry
no longer needs the page an returns it to the pool of page instances]
If you fail to clear the variables in initialize, other users could
potentially get that data.
As for defining the table source - please give some more details on how
you're binding to contrib:Table. Hard to say without those details.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org