You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Anatoly Kupriyanov <ka...@gmail.com> on 2011/12/29 15:48:45 UTC

AJAX on large page

Hi everybody!

I have a page which displays long list of messages. I use
LoadableDetachableModel for the list view, because it should display the
latest messages each time page renders. Each message has a ajax button to
make some action on the message. Each time I click the button, wicket loads
the list, looks up for the message (by index? or how?) and invokes my
"onClick" method.
It doesn't look great. What is a better approach to do it?
I want minimize memory usage (don't keep in session list of all messages)
and avoid querying the whole list each time from database (moreover, it is
changing!). The wise solution is to somehow refer a concrete button to a
message by the message PK and query only the message, but I don't know an
elegant way to do it, only fighting with the wicket approach.

-- 
WBR, Anatoly.

Re: AJAX on large page

Posted by Anatoly Kupriyanov <ka...@gmail.com>.
Thanks for the answer, Ernesto.

A message has quite complex layout, it would be a lot of work to redo it in
json. And I lose all benefits of wicket tester...
Yes, that's that I mean by fighting the wicket, do everything manually, not
using the wicket...
Is it only solution?
It worries me because I have to rewrite quite a few such pages - if a page
has a lot of data, I cannot use wicket's AJAX abilities.

On 29 December 2011 15:06, Ernesto Reinaldo Barreiro <re...@gmail.com>wrote:

> Anatoly,
>
> I would do more or less the following
>
> 1-Created a panel with an AbstractAjaxBehavior on it.
> 2-Use that behavior as context for rendering JSON format and handling row
> clicks.
> 3-Build the list using JSON+JavaScript. Each row could be built out of JSON
> data:  when panel is loaded use some JavaScript to query back the behavior
> for JSON and build rows using that data. The onClick of the each button
> would point to the same AJAX behavior but pass the "index" of the row as
> parameter.
>
> This way you would have a very lightweight component.
>
> Regards,
>
> Ernesto
>
>
> On Thu, Dec 29, 2011 at 3:48 PM, Anatoly Kupriyanov <kan.izh@gmail.com
> >wrote:
>
> > Hi everybody!
> >
> > I have a page which displays long list of messages. I use
> > LoadableDetachableModel for the list view, because it should display the
> > latest messages each time page renders. Each message has a ajax button to
> > make some action on the message. Each time I click the button, wicket
> loads
> > the list, looks up for the message (by index? or how?) and invokes my
> > "onClick" method.
> > It doesn't look great. What is a better approach to do it?
> > I want minimize memory usage (don't keep in session list of all messages)
> > and avoid querying the whole list each time from database (moreover, it
> is
> > changing!). The wise solution is to somehow refer a concrete button to a
> > message by the message PK and query only the message, but I don't know an
> > elegant way to do it, only fighting with the wicket approach.
> >
> > --
> > WBR, Anatoly.
> >
>



-- 
WBR, Anatoly.

Re: AJAX on large page

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Anatoly,

I would do more or less the following

1-Created a panel with an AbstractAjaxBehavior on it.
2-Use that behavior as context for rendering JSON format and handling row
clicks.
3-Build the list using JSON+JavaScript. Each row could be built out of JSON
data:  when panel is loaded use some JavaScript to query back the behavior
for JSON and build rows using that data. The onClick of the each button
would point to the same AJAX behavior but pass the "index" of the row as
parameter.

This way you would have a very lightweight component.

Regards,

Ernesto


On Thu, Dec 29, 2011 at 3:48 PM, Anatoly Kupriyanov <ka...@gmail.com>wrote:

> Hi everybody!
>
> I have a page which displays long list of messages. I use
> LoadableDetachableModel for the list view, because it should display the
> latest messages each time page renders. Each message has a ajax button to
> make some action on the message. Each time I click the button, wicket loads
> the list, looks up for the message (by index? or how?) and invokes my
> "onClick" method.
> It doesn't look great. What is a better approach to do it?
> I want minimize memory usage (don't keep in session list of all messages)
> and avoid querying the whole list each time from database (moreover, it is
> changing!). The wise solution is to somehow refer a concrete button to a
> message by the message PK and query only the message, but I don't know an
> elegant way to do it, only fighting with the wicket approach.
>
> --
> WBR, Anatoly.
>

Re: AJAX on large page

Posted by Anatoly Kupriyanov <ka...@gmail.com>.
Thank you! It looks more promising.

On 29 December 2011 16:54, Sven Meier <sv...@meiers.net> wrote:

> Switch to a DataTable, IDataProvider has #model() exactly for your usecase.
>
> And if you haven't already, read
>  http://wicketinaction.com/**2008/09/building-a-smart-**entitymodel/<http://wicketinaction.com/2008/09/building-a-smart-entitymodel/>
>
> Sven
>
>
> On 12/29/2011 03:48 PM, Anatoly Kupriyanov wrote:
>
>> Hi everybody!
>>
>> I have a page which displays long list of messages. I use
>> LoadableDetachableModel for the list view, because it should display the
>> latest messages each time page renders. Each message has a ajax button to
>> make some action on the message. Each time I click the button, wicket
>> loads
>> the list, looks up for the message (by index? or how?) and invokes my
>> "onClick" method.
>> It doesn't look great. What is a better approach to do it?
>> I want minimize memory usage (don't keep in session list of all messages)
>> and avoid querying the whole list each time from database (moreover, it is
>> changing!). The wise solution is to somehow refer a concrete button to a
>> message by the message PK and query only the message, but I don't know an
>> elegant way to do it, only fighting with the wicket approach.
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
WBR, Anatoly.

Re: AJAX on large page

Posted by Sven Meier <sv...@meiers.net>.
Switch to a DataTable, IDataProvider has #model() exactly for your usecase.

And if you haven't already, read
   http://wicketinaction.com/2008/09/building-a-smart-entitymodel/

Sven

On 12/29/2011 03:48 PM, Anatoly Kupriyanov wrote:
> Hi everybody!
>
> I have a page which displays long list of messages. I use
> LoadableDetachableModel for the list view, because it should display the
> latest messages each time page renders. Each message has a ajax button to
> make some action on the message. Each time I click the button, wicket loads
> the list, looks up for the message (by index? or how?) and invokes my
> "onClick" method.
> It doesn't look great. What is a better approach to do it?
> I want minimize memory usage (don't keep in session list of all messages)
> and avoid querying the whole list each time from database (moreover, it is
> changing!). The wise solution is to somehow refer a concrete button to a
> message by the message PK and query only the message, but I don't know an
> elegant way to do it, only fighting with the wicket approach.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org