For those who are interested the solution to my problem. Which is I must say
due to me being thick is:
In the .page have:
<property name="users">getAllUsers()</property>
In the class have:
public List getAllUsers() {
// some code that returns the list of users
// this is the method which lazily gets the info
}
abstract List getUsers(); and abstract void setUsers(List users); still
exist and can be used to retrieve the modified list from the table.
This solution was got from Radim Burget <[EMAIL PROTECTED]> post on 15
September 2005 22:34:52 Subject : Re: contrib Table sorting.
This will hopefully be of some use to someone else.
Paul
seloha . <[EMAIL PROTECTED]> wote:
The solution you mentioned in the first place with 'keyExpression' did solve
my initial problem.
The problem with the table now is that I cannot sort it. This would appear
to be because I initialize the data in the pageBeginRender() method.
The problem I am having if I move the data initialization to a method as
suggested I loose the enhanced abstract method of the same name. After
updating the information in the table I used to get the updated information
using the abstract get method. So taking an example of users being the table
'source' I used to have something like this:
public abstract List getUsers();
public abstract void);
public void pageBeginRender(PageEvent event) {
setUsers(getUsersDaoManager().getAllUsers());
}
public void formSubmit(IRequestCycle cycle) {
getUsersDaoManager().updateAllUsers(getUsers());
}
This is not a real section of code, so may contain errors, but will
hopefully illustrate what I am trying to get at.
If I were to have:
public List getUsers() {
getUsersDaoManager().getAllUsers();
}
The formSubmit(IRequestCycle cycle) could not use getUsers() for the updated
information which has been entered in the table. As I said before I could
well be very stupid but I am unable to get the updated information entered
by a user in the table with this pattern.
Thanks for your response,
Paul
Mind Bridge wrote:
Hi,
The problem I have then is when I update the data in the table I can no
longer use the getUsers() > method to obtain the updated data from the
table.
I am not entirely sure, is this a different problem? You mentioned something
like that earlier -- did 'keyExpression' do the trick? If I understand
correctly, this is unrelated to the lazy initialization issue.
The reason for the problem you were getting was that For was returning
different _physical_ objects with identical contents. Basically, it was
serializing the objects (or their primary keys) into hidden fields and was
then deserializing them in the next request cycle, receiving different
objects with identical contents in the process. Since the new objects were
apprently not stored, you were getting the problem that you described, even
though everything else was okay.
I am about to check in a modification of the code that ensures that by
default For (and thus Table) will try to keep the values the same as those
provided in 'source' by trying to find values in there with identical string
representations to those stored. That would resolve your problem completely
with no effort on your part.
'keyExpression' is the solution for the current version, as it forces For to
do exactly that matching anyway. There will be no need to use it in that
case soon, however.
-mb
seloha . wrote:
Is it okay if I butt in here and mention that I have had the same problem,
and it is, from what Mind Bridge says, because I initialize the data in
pageBeginRender(). The problem I have then is when I update the data in the
table I can no longer use the getUsers() method to obtain the updated data
from the table. I might not be thinking here but what is the simple solution
to obtain the updated data if the suggested action is taken.
I could be being stupid here (which is not unusual),
Paul
Mind Bridge wrote:
The sorting listener is invoked before the page rendering starts. As a
result, getUsers() is called before pageBeginRender(). If you initialize
your variables there, you are going to get that problem.
I would suggest a lazy intialization in getUsers() -- that should resolve
the issue.
Radim Burget wrote:
Hi,
I am trying to google answer on how to disable caching in contrib:table
component to be working with sorting and page listing but without success.
Here is my Home.page tab definition:
<component id="table" type="contrib:Table">
<binding name="source" value="users"/>
<binding name="columns" value="Full Name:fullName,Email:email, Phone
Number:phoneNumber, !action"/>
<binding name="columnsClass" value="literal:title"/>
<binding name="pageSize" value="2"/>
</component>
(Tapestry 4.0beta-4)
On sorting or page listing is thrown exception:
Either the tableModel parameter or both source and columns parameters must
be specified by component SelectAccount/table.tableView
If I make values cached with:
<binding name="tableSessionStateManager" value="new
org.apache.tapestry.contrib.table.model.common.FullTableSessionStateManager()"/>
everything is ok. But I need to not to cache data, because they are changed
quite often.
Could anyone help me?
Thanks in advance
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]