Discussion:
AjaxSelfUpdatingBehaviour detaches my DataTable
Sandor Feher
2018-10-29 15:54:47 UTC
Permalink
Hi,


I succesfuly implemented my session expiration solution described in my
recent post:
http://apache-wicket.1842946.n4.nabble.com/Handling-session-timeout-properly-td4675541.html
and I use the same behavior for refreshing my NotificationPanel too.

My only problem/observation that AjaxSelfUpdatingBehaviour detaches my
DataTable/DataProvider too although it has nothing to do with them. (It
detaches at every 10 second when my Notification panel get refreshed).

I'm just wondering if it is the expected behaviour or I missed something.

I created a quickstart for demonstrating the situation.
Sorry for the mess, I did not have too much time to prettify but I hope you
will get the root point.

https://github.com/sfeher/selfupdatingbehavoiurquickstart

TIA, Sandor

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2018-10-29 21:07:16 UTC
Permalink
Hi,

AjaxRequestHandler detaches the whole page, so not only the updated
components.

Have fun
Sven
Post by Sandor Feher
Hi,
I succesfuly implemented my session expiration solution described in my
http://apache-wicket.1842946.n4.nabble.com/Handling-session-timeout-properly-td4675541.html
and I use the same behavior for refreshing my NotificationPanel too.
My only problem/observation that AjaxSelfUpdatingBehaviour detaches my
DataTable/DataProvider too although it has nothing to do with them. (It
detaches at every 10 second when my Notification panel get refreshed).
I'm just wondering if it is the expected behaviour or I missed something.
I created a quickstart for demonstrating the situation.
Sorry for the mess, I did not have too much time to prettify but I hope you
will get the root point.
https://github.com/sfeher/selfupdatingbehavoiurquickstart
TIA, Sandor
--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sandor Feher
2018-10-30 06:59:14 UTC
Permalink
Hi Sven,

Ok, thanks.

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sandor Feher
2018-11-12 13:12:42 UTC
Permalink
Hi,

I feel a little bit dump but I can't fix it.

At the moment it looks like if I want my DataTable get reloaded then I must
call explicitly a public method in my DataProvider.

So far I simply called detachModel() on my DataTable and in detach method I
reloaded list using my DAO.
Because of AwareAjaxSelfUpdatingBehaviour (which is in my HeaderPanel which
is included by BasePage and every page classes extend the BasePage) all
pages get detached in every second.

TIA, Sandor

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Bas Gooren
2018-11-14 20:30:21 UTC
Permalink
Hi Sandor,

Can you explain more clearly (step by step, request by request) what is
happening and what you expect to happen?

Most dataproviders (e.g. ones backed by a database model) reload their
underlying data on every request, so reloading should be easy (simply add
the datatable to the ajax request or reload the entire page).
What kind of data provider are you using?

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 12 november 2018 bij 14:19:09, Sandor Feher (***@bluesystem.hu)
schreef:

Hi,

I feel a little bit dump but I can't fix it.

At the moment it looks like if I want my DataTable get reloaded then I must
call explicitly a public method in my DataProvider.

So far I simply called detachModel() on my DataTable and in detach method I
reloaded list using my DAO.
Because of AwareAjaxSelfUpdatingBehaviour (which is in my HeaderPanel which
is included by BasePage and every page classes extend the BasePage) all
pages get detached in every second.

TIA, Sandor
--
Sent from:
http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sandor Feher
2018-11-14 21:38:56 UTC
Permalink
Hi,

Sorry for the confusing.
Let me explain it more.
Let's suppose a simple CRUD page with a single DataTable and it's
dataprovider.
I need to refresh my datatable after a new item added.

So far I did it like this:

mw = new ModalWindow("modal");
mw.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
private static final long serialVersionUID = 1L;

@Override
public void onClose(AjaxRequestTarget target) {
dataTable.detachModels();
target.add(wm_bottom);
}
});

In my dataprovider I reloaded data when datatable (and dataprovider) got
detached.

@Override
public void detach() {
myDAO.refreshData();
}

and every other cases when datatable filtered or cleared and so one.
And at this point AjaxSelfupdatingBehaviour comes in the picture. I can't
rely on ondetach method anymore because it's fired in every second not just
when it needed.

I hope I need a different approach to refresh my data but I did not figure
it out so far.

Regards, Sandor

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2018-11-14 22:01:16 UTC
Permalink
Hi Sandor,

why doesn't your myDAO 'detach'(=clear) its cache automatically whenever
a new item is added?

Wicket might call #detach() in a lot of circumstances, thus this has to
be a very quick operation.

It's better to avoid tying your caching to your UI layer. If you're
using Spring, you can add caching to your service via annotations quite
easily:

https://docs.spring.io/spring/docs/4.0.x/spring-framework-reference/html/cache.html

Have fun
Sven
Post by Sandor Feher
Hi,
Sorry for the confusing.
Let me explain it more.
Let's suppose a simple CRUD page with a single DataTable and it's
dataprovider.
I need to refresh my datatable after a new item added.
mw = new ModalWindow("modal");
mw.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
private static final long serialVersionUID = 1L;
@Override
public void onClose(AjaxRequestTarget target) {
dataTable.detachModels();
target.add(wm_bottom);
}
});
In my dataprovider I reloaded data when datatable (and dataprovider) got
detached.
@Override
public void detach() {
myDAO.refreshData();
}
and every other cases when datatable filtered or cleared and so one.
And at this point AjaxSelfupdatingBehaviour comes in the picture. I can't
rely on ondetach method anymore because it's fired in every second not just
when it needed.
I hope I need a different approach to refresh my data but I did not figure
it out so far.
Regards, Sandor
--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sandor Feher
2018-11-19 11:00:10 UTC
Permalink
Hi Sven,

Sorry, I did not notice your answer so far.
Okay. Let's try to see things from different angle :)

Yes I use spring. I tried to reduce the number of unnecessary queries. To
achieve this I try to catch if my table filtered or a new item added or a
dropdownchoice changed and so on.

It works more or less but there is no method to catch an ajax table refresh
for example (Catching it in detach() method is bad practice you made me
sure)

Here is a simple DataProvider I use. The question is that which point
should I reload data using customBo?

At size() or Iterator ? What is the best practice for this ?







--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
sven
2018-11-22 17:39:54 UTC
Permalink
Hi,



If your queries are so expensive you can just keep its results as a member in your component. Make a new query each time a filter changes, and let your dataProvider just iterate over the cached list.



Note that your Data gets serialized with your page though.



Sven
Loading...