You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by kshitiz <k....@gmail.com> on 2012/08/30 21:21:34 UTC

size method is being called multiple times in dataview

Hi,

I am trying to implement dataview:


final IDataProvider<PostDomain> postDomainDataProvider = new
IDataProvider<PostDomain>() {
			
			/**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			@Override
			public void detach() {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public int size() {
				// TODO Auto-generated method stub
				System.out.println("Data view size called");
				try {
					return list.size();
				} catch (Exception exception) {
					// TODO Auto-generated catch block
					exception.printStackTrace();
					return 0;
				}
			}
			
			@Override
			public IModel<PostDomain> model(final PostDomain object) {
				// TODO Auto-generated method stub
				return new LoadableDetachableModel<PostDomain>() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					protected PostDomain load() {
						return object;
					}
				};
			}
			
			@Override
			public Iterator<? extends PostDomain> iterator(int first, int count) {
				// TODO Auto-generated method stub
				System.out.println("Dataview iterator called");
				try {
					return getList(count, first).iterator();
				} catch (PostNotFoundException postNotFoundException) {
					postNotFoundException.printStackTrace();
				} catch (Exception exception) {
					// TODO Auto-generated catch block
					exception.printStackTrace();
				}
				return null;
			}
		};


Now what is happening is size() method is getting called many times before
dataView is rendered. There is                  no looping situation over
here and if there would be any infinite looping, then dataView wont have
rendered.
size() can return any thing from 0 to 100..and I have set
dataView.setItemPerPage(20).

What can be the reason? 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/size-method-is-being-called-multiple-times-in-dataview-tp4651666.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: size method is being called multiple times in dataview

Posted by kshitiz <k....@gmail.com>.
Hi,

Sorry for replying late ..:(...I am using wicket 1.5. I dont know what
causing this issue...but I am looking for other way around to solve my
purpose...



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/size-method-is-being-called-multiple-times-in-dataview-tp4651666p4651683.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: size method is being called multiple times in dataview

Posted by Sven Meier <sv...@meiers.net>.
Just tried with breakpoints in the datatable examples (e.g. 
org.apache.wicket.examples.repeater.SortingPage) and #size() was called 
once only for each request.

Which Wicket version?

Sven

On 08/30/2012 09:21 PM, kshitiz wrote:
> Hi,
>
> I am trying to implement dataview:
>
>
> final IDataProvider<PostDomain> postDomainDataProvider = new
> IDataProvider<PostDomain>() {
> 			
> 			/**
> 			 *
> 			 */
> 			private static final long serialVersionUID = 1L;
>
> 			@Override
> 			public void detach() {
> 				// TODO Auto-generated method stub
> 				
> 			}
> 			
> 			@Override
> 			public int size() {
> 				// TODO Auto-generated method stub
> 				System.out.println("Data view size called");
> 				try {
> 					return list.size();
> 				} catch (Exception exception) {
> 					// TODO Auto-generated catch block
> 					exception.printStackTrace();
> 					return 0;
> 				}
> 			}
> 			
> 			@Override
> 			public IModel<PostDomain> model(final PostDomain object) {
> 				// TODO Auto-generated method stub
> 				return new LoadableDetachableModel<PostDomain>() {
> 					
> 					/**
> 					 *
> 					 */
> 					private static final long serialVersionUID = 1L;
>
> 					@Override
> 					protected PostDomain load() {
> 						return object;
> 					}
> 				};
> 			}
> 			
> 			@Override
> 			public Iterator<? extends PostDomain> iterator(int first, int count) {
> 				// TODO Auto-generated method stub
> 				System.out.println("Dataview iterator called");
> 				try {
> 					return getList(count, first).iterator();
> 				} catch (PostNotFoundException postNotFoundException) {
> 					postNotFoundException.printStackTrace();
> 				} catch (Exception exception) {
> 					// TODO Auto-generated catch block
> 					exception.printStackTrace();
> 				}
> 				return null;
> 			}
> 		};
>
>
> Now what is happening is size() method is getting called many times before
> dataView is rendered. There is                  no looping situation over
> here and if there would be any infinite looping, then dataView wont have
> rendered.
> size() can return any thing from 0 to 100..and I have set
> dataView.setItemPerPage(20).
>
> What can be the reason?
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/size-method-is-being-called-multiple-times-in-dataview-tp4651666.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