You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by sudeivas <su...@gmail.com> on 2012/05/09 19:54:47 UTC
Loadable-detachable model for ListView
Hello,
Can any one please provide an example for implementing a list view with
loadable-detachable model? I am trying to minimize the size of the session.
Because sometimes, the size of the list view can be more than 2000, and this
occupies lot of space in session.
Also is there a better way to handle this list view to populate only 100 at
a time and when the user scrolls down the list, we will populate more
entries. We have a backend service which support pagination.
Thanks,
Suresh
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable-detachable model for ListView
Posted by vineet semwal <vi...@gmail.com>.
same same
On Fri, May 11, 2012 at 12:58 AM, sudeivas <su...@gmail.com> wrote:
> Thanks Dan. Final question to you guys,
>
> Option 1:
> DataView<SerializableWorkflowInstancePartial> dataview =
> new DataView<SerializableWorkflowInstancePartial>("problems",
> new UsersProvider()) {
> private static final long serialVersionUID = 1L;
>
> @Override
> protected void populateItem(final Item item) {
> item.add(new
> Label("title",*((SerializableWorkflowInstancePartial)
> item.getModelObject()).*getFriendlyName(getLocale())).setRenderBodyOnly(true));
> item.add(new
> Label("location",(*(SerializableWorkflowInstancePartial)
> item.getModelObject())*.getCreatedLocation()).setRenderBodyOnly(true));
> item.add(new
> Label("age",*((SerializableWorkflowInstancePartial)
> item.getModelObject())*.getAgeString()).setRenderBodyOnly(true));
> }
> }
> };
>
> Option 2:
> DataView<SerializableWorkflowInstancePartial> dataview =
> new DataView<SerializableWorkflowInstancePartial>("problems",
> new UsersProvider()) {
> private static final long serialVersionUID = 1L;
>
> @Override
> protected void populateItem(final Item item) {
> *SerializableWorkflowInstancePartial workflow =
> (SerializableWorkflowInstancePartial) item.getModelObject();*
> item.add(new
> Label("title",workflow.getFriendlyName(getLocale())).setRenderBodyOnly(true));
> item.add(new
> Label("location",workflow.getCreatedLocation()).setRenderBodyOnly(true));
> item.add(new
> Label("age",workflow.getAgeString()).setRenderBodyOnly(true));
> }
> }
> };
>
> Is there any difference between option 1 and 2. Or do I always have to use
> item.getModelObject() for all my components to avoid session storage.
>
> -Suresh
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4624389.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
--
thank you,
regards,
Vineet Semwal
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable-detachable model for ListView
Posted by sudeivas <su...@gmail.com>.
Thanks Dan. Final question to you guys,
Option 1:
DataView<SerializableWorkflowInstancePartial> dataview =
new DataView<SerializableWorkflowInstancePartial>("problems",
new UsersProvider()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final Item item) {
item.add(new
Label("title",*((SerializableWorkflowInstancePartial)
item.getModelObject()).*getFriendlyName(getLocale())).setRenderBodyOnly(true));
item.add(new
Label("location",(*(SerializableWorkflowInstancePartial)
item.getModelObject())*.getCreatedLocation()).setRenderBodyOnly(true));
item.add(new
Label("age",*((SerializableWorkflowInstancePartial)
item.getModelObject())*.getAgeString()).setRenderBodyOnly(true));
}
}
};
Option 2:
DataView<SerializableWorkflowInstancePartial> dataview =
new DataView<SerializableWorkflowInstancePartial>("problems",
new UsersProvider()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final Item item) {
*SerializableWorkflowInstancePartial workflow =
(SerializableWorkflowInstancePartial) item.getModelObject();*
item.add(new
Label("title",workflow.getFriendlyName(getLocale())).setRenderBodyOnly(true));
item.add(new
Label("location",workflow.getCreatedLocation()).setRenderBodyOnly(true));
item.add(new
Label("age",workflow.getAgeString()).setRenderBodyOnly(true));
}
}
};
Is there any difference between option 1 and 2. Or do I always have to use
item.getModelObject() for all my components to avoid session storage.
-Suresh
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4624389.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable-detachable model for ListView
Posted by Dan Retzlaff <dr...@gmail.com>.
I may have been wrong about that... I can't setup a test app right now, but
I think the default configuration of DataView also discards models on
detach. Sorry for the confusion.
On Thu, May 10, 2012 at 12:06 PM, sudeivas <su...@gmail.com>wrote:
> Dan has mentioned "I think
> ListView is better than DataView because it naturally discards its contents
> after the request where data view saves models, keeping your session size
> the same."
>
> So if my list has 1000 entries, will the session store all these values if
> I
> use DataView/IDataProvider and LoadableDetachableModel?
>
> -Suresh
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4624338.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Loadable-detachable model for ListView
Posted by sudeivas <su...@gmail.com>.
Dan has mentioned "I think
ListView is better than DataView because it naturally discards its contents
after the request where data view saves models, keeping your session size
the same."
So if my list has 1000 entries, will the session store all these values if I
use DataView/IDataProvider and LoadableDetachableModel?
-Suresh
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4624338.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable-detachable model for ListView
Posted by Igor Vaynberg <ig...@gmail.com>.
which objects get stored in session?
-igor
On Thu, May 10, 2012 at 11:30 AM, sudeivas <su...@gmail.com> wrote:
> Hello Igor & Dan,
> Can you please answer the question regarding storing objects in
> Session for DataView?
> Why does it store objects in Session since we are using LDM?
>
> -Suresh
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4624239.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable-detachable model for ListView
Posted by sudeivas <su...@gmail.com>.
Hello Igor & Dan,
Can you please answer the question regarding storing objects in
Session for DataView?
Why does it store objects in Session since we are using LDM?
-Suresh
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4624239.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable-detachable model for ListView
Posted by heapifyman <he...@gmail.com>.
by examples page I meant:
http://www.wicket-library.com/wicket-examples/repeater/
2012/5/10 heapifyman <he...@gmail.com>
> The examples page does not seem to be working:
> HTTP Status 500 -
> ------------------------------
>
> *type* Exception report
>
> *message***
>
> *description* *The server encountered an internal error () that prevented
> it from fulfilling this request.*
>
> *exception*
>
> javax.servlet.ServletException: Filter execution threw an exception
>
> *root cause*
>
> java.lang.OutOfMemoryError: PermGen space
>
> *note* *The full stack trace of the root cause is available in the Apache
> Tomcat/6.0.29 logs.*
>
>
>
>
> 2012/5/10 Igor Vaynberg <ig...@gmail.com>
>
>> use PagingNavigator. there are examples here:
>>
>> http://www.wicket-library.com/wicket-examples/repeater/
>>
>> -igor
>>
>> On Wed, May 9, 2012 at 4:11 PM, sudeivas <su...@gmail.com>
>> wrote:
>> > Thanks Igor for the response.
>> >
>> > If I use dataview.setItemsPerPage(50), then my Data View loads only the
>> > first 50 entries. But how can I trigger or ask the data view to load the
>> > next 50 entries when we scroll down the list or when we reach the end
>> of the
>> > list?
>> >
>> > -Suresh
>> >
>> > --
>> > View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4622091.html
>> > Sent from the Users forum mailing list archive at Nabble.com.
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
Re: Loadable-detachable model for ListView
Posted by heapifyman <he...@gmail.com>.
The examples page does not seem to be working:
HTTP Status 500 -
------------------------------
*type* Exception report
*message***
*description* *The server encountered an internal error () that prevented
it from fulfilling this request.*
*exception*
javax.servlet.ServletException: Filter execution threw an exception
*root cause*
java.lang.OutOfMemoryError: PermGen space
*note* *The full stack trace of the root cause is available in the Apache
Tomcat/6.0.29 logs.*
2012/5/10 Igor Vaynberg <ig...@gmail.com>
> use PagingNavigator. there are examples here:
>
> http://www.wicket-library.com/wicket-examples/repeater/
>
> -igor
>
> On Wed, May 9, 2012 at 4:11 PM, sudeivas <su...@gmail.com>
> wrote:
> > Thanks Igor for the response.
> >
> > If I use dataview.setItemsPerPage(50), then my Data View loads only the
> > first 50 entries. But how can I trigger or ask the data view to load the
> > next 50 entries when we scroll down the list or when we reach the end of
> the
> > list?
> >
> > -Suresh
> >
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4622091.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Loadable-detachable model for ListView
Posted by Igor Vaynberg <ig...@gmail.com>.
use PagingNavigator. there are examples here:
http://www.wicket-library.com/wicket-examples/repeater/
-igor
On Wed, May 9, 2012 at 4:11 PM, sudeivas <su...@gmail.com> wrote:
> Thanks Igor for the response.
>
> If I use dataview.setItemsPerPage(50), then my Data View loads only the
> first 50 entries. But how can I trigger or ask the data view to load the
> next 50 entries when we scroll down the list or when we reach the end of the
> list?
>
> -Suresh
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4622091.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable-detachable model for ListView
Posted by sudeivas <su...@gmail.com>.
thanks for the info Dan.
I haven't worked with Jquery before. I will explore more on that. But I am
curious to know why DataView stores information in the session. Because I
use LoadableDetachableModel in my above example. The main objective for me
is minimize the information stored in session. Our backend service is very
quick in sending all the entries we need for the list.
-Suresh
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4622292.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable-detachable model for ListView
Posted by Dan Retzlaff <dr...@gmail.com>.
Suresh,
I haven't seen a packaged solution for inifinte scroll in Wicket. But the
way I'd implement it is to detect that more content is needed with
JavaScript (some kind of jQuery event listeners), then make a request to a
Wicket AJAX behavior. I'd have the behavior render content into a hidden
list view, then use jQuery to move those list view items to the bottom of
the visible list. This way each response only sends new content. I think
ListView is better than DataView because it naturally discards its contents
after the request where data view saves models, keeping your session size
the same. You should probably pass the current "page" of results as a query
parameter in your AJAX behavior request (instead of keeping that state
server-side). That way if the user reloads the page, they simply go back to
the first page of results.
Hope that helps.
Dan
On Wed, May 9, 2012 at 4:11 PM, sudeivas <su...@gmail.com> wrote:
> Thanks Igor for the response.
>
> If I use dataview.setItemsPerPage(50), then my Data View loads only the
> first 50 entries. But how can I trigger or ask the data view to load the
> next 50 entries when we scroll down the list or when we reach the end of
> the
> list?
>
> -Suresh
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4622091.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Loadable-detachable model for ListView
Posted by sudeivas <su...@gmail.com>.
Thanks Igor for the response.
If I use dataview.setItemsPerPage(50), then my Data View loads only the
first 50 entries. But how can I trigger or ask the data view to load the
next 50 entries when we scroll down the list or when we reach the end of the
list?
-Suresh
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4622091.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable-detachable model for ListView
Posted by Igor Vaynberg <ig...@gmail.com>.
call dataview.setitemsperpage(x)
-igor
On Wed, May 9, 2012 at 3:32 PM, sudeivas <su...@gmail.com> wrote:
> I am using the below code in my application. But the data provider makes a
> call to my service wrapper asking for all the entries. For example: if total
> size of the list of 750, the first - 0 and count - 750. This is not
> different from using list view. How can I make sure that this data view
> loads (for example 100 entries) at a time. And when user scroll down the
> list, we load more entries. Is it possible?
>
> class UsersProvider implements IDataProvider
> {
> private static final long serialVersionUID = 1L;
> public Iterator iterator(int first, int count)
> {
> Iterator<SerializableWorkflowInstancePartial> iterator =
> null;
> try {
> iterator =
> WorkflowServiceWrapper.listOpenActiveWorkflowInstances(
> category, first, count);
> } catch (DependencyFailureException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> return iterator;
> }
>
> public int size()
> {
> return getProblemsCount();
> }
>
> public IModel model(final Object object)
> {
> return new LoadableDetachableModel() {
> private static final long serialVersionUID = 1L;
> protected Object load() {
> return object;
> }
> };
> }
>
> @Override
> public void detach() {
> LOGGER.info("coming to detach");
> // TODO Auto-generated method stub
> }
> }
>
> DataView<SerializableWorkflowInstancePartial> dataview =
> new DataView<SerializableWorkflowInstancePartial>("problems",
> new UsersProvider()) {
> private static final long serialVersionUID = 1L;
>
> @Override
> protected void populateItem(final Item item) {
> Label blockedImage = new Label("blockedImage","");
> if(((SerializableWorkflowInstancePartial)
> item.getModelObject()).isBlocking()) {
>
> //do something and add all ui compoenents
> }
> };
> add(container);
> container.add(dataview);
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4622002.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable-detachable model for ListView
Posted by sudeivas <su...@gmail.com>.
I am using the below code in my application. But the data provider makes a
call to my service wrapper asking for all the entries. For example: if total
size of the list of 750, the first - 0 and count - 750. This is not
different from using list view. How can I make sure that this data view
loads (for example 100 entries) at a time. And when user scroll down the
list, we load more entries. Is it possible?
class UsersProvider implements IDataProvider
{
private static final long serialVersionUID = 1L;
public Iterator iterator(int first, int count)
{
Iterator<SerializableWorkflowInstancePartial> iterator =
null;
try {
iterator =
WorkflowServiceWrapper.listOpenActiveWorkflowInstances(
category, first, count);
} catch (DependencyFailureException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return iterator;
}
public int size()
{
return getProblemsCount();
}
public IModel model(final Object object)
{
return new LoadableDetachableModel() {
private static final long serialVersionUID = 1L;
protected Object load() {
return object;
}
};
}
@Override
public void detach() {
LOGGER.info("coming to detach");
// TODO Auto-generated method stub
}
}
DataView<SerializableWorkflowInstancePartial> dataview =
new DataView<SerializableWorkflowInstancePartial>("problems",
new UsersProvider()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final Item item) {
Label blockedImage = new Label("blockedImage","");
if(((SerializableWorkflowInstancePartial)
item.getModelObject()).isBlocking()) {
//do something and add all ui compoenents
}
};
add(container);
container.add(dataview);
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232p4622002.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable-detachable model for ListView
Posted by Igor Vaynberg <ig...@gmail.com>.
use DataView/IDataProvider
-igor
On Wed, May 9, 2012 at 10:54 AM, sudeivas <su...@gmail.com> wrote:
> Hello,
> Can any one please provide an example for implementing a list view with
> loadable-detachable model? I am trying to minimize the size of the session.
> Because sometimes, the size of the list view can be more than 2000, and this
> occupies lot of space in session.
>
> Also is there a better way to handle this list view to populate only 100 at
> a time and when the user scrolls down the list, we will populate more
> entries. We have a backend service which support pagination.
>
> Thanks,
> Suresh
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-detachable-model-for-ListView-tp4621232.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org