You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by kristian_widjaja <kr...@yahoo.com> on 2010/03/04 10:09:33 UTC

Re: Table throws exception when the amount of retrieved data is less than its page size

Hi, Bob and Malcolm. Thanks for replying.

To Bob, 
Have you tried to set the pageSize larger than the actual amount of
available data by using "DataProvider"? Cause the problem arise when that
strategy is implemented.

To Malcolm,
I am using JDBC wrapped by iBatis. Method to retrieved the list of data is
below : 

<code>
private List<MemberUsers> getMemberUsersList() {
		int offset = 1;

		if (StringUtils.hasLength(page)) {
			int pageNumber = Integer.parseInt(page);
			offset = pageNumber * AppConstants.PAGING_COUNT; // PAGING_COUNT = 10;
		}

		return memberUsersService.getUsersListByVirtualId(
				getPreservedState().toString(), offset, AppConstants.PAGING_COUNT);
	}
</code>


The query is listed below: 

<code>
select USER_ID, VIRTUAL_ID, JOIN_DT, STATUS, NAME, BIRTH_DT, EMAIL, PHONE,
UPLINE
    from ( select a.USER_ID, a.VIRTUAL_ID, a.JOIN_DT, a.STATUS, a.NAME,
a.BIRTH_DT, a.EMAIL, 
    			  a.PHONE, a.UPLINE, rownum rnum
           from (
           		select USER_ID, VIRTUAL_ID, JOIN_DT, STATUS, NAME, BIRTH_DT,
EMAIL, PHONE, UPLINE
    	 		from GNGUSER.MEMBER_USERS 
            ) a
           where rownum <= #maxRows# 
         )
    where rnum >= #minRows#
</code>

Anyway, as available records only 5 records currently, so when i set the
'pageSize = 5' and constant 'PAGING_COUNT = 5', it works well. As i
mentioned before, only when i set 'pageSize' larger than actual available
data count then the exception is thrown. Thanks.

Regards,
Kristian Widjaja.
-- 
View this message in context: http://n2.nabble.com/Table-throws-exception-when-the-amount-of-retrieved-data-is-less-than-its-page-size-tp4672850p4673121.html
Sent from the click-user mailing list archive at Nabble.com.

Re: Table throws exception when the amount of retrieved data is less than its page size

Posted by kristian_widjaja <kr...@yahoo.com>.
Hi, henry

Sure, here is the code : 

<code>
private int getMemberUsersRecordCount() { // getLoggedInUserName() = e.g.
'12341234'
	return memberUsersService.getUserCountByVirtualId(getLoggedInUserName());
}

public class MemberUsersService implement MemberUsersService {
        ...
        public List<MemberUsers> getUsersListByVirtualId(String virtualId)
throws Exception {
		log.debug("# Get user list by virtual id: " + virtualId);

		MemberUsersCriteria criteria = new MemberUsersCriteria();
		criteria.createCriteria().andVirtualIdEqualTo(virtualId);

		return memberUsersDAO.selectMemberUsersByExample(criteria);
	}
}
</code>

And this is the query in file MemberUsersService_sqlmap.xml : 

<code>
<select id="ibatorgenerated_countByExample"
parameterClass="com.gng.db.core.ibatis.entity.MemberUsersCriteria"
resultClass="java.lang.Integer">
    <!--
      WARNING - This element is automatically generated by Apache iBATIS
ibator, do not modify.
      This element was generated on Wed Mar 03 21:40:17 ICT 2010.
    -->
    select count(*) from GNGUSER.MEMBER_USERS
    <include
refid="GNGUSER_MEMBER_USERS.ibatorgenerated_Example_Where_Clause" />
  </select>
</code>

** where the '<include ' will be replaced by : "WHERE VIRTUAL_ID =
#virtualId#".

Regards,
Kristian W.
-- 
View this message in context: http://n2.nabble.com/Table-throws-exception-when-the-amount-of-retrieved-data-is-less-than-its-page-size-tp4672850p4673468.html
Sent from the click-user mailing list archive at Nabble.com.

Re: Table throws exception when the amount of retrieved data is less than its page size

Posted by Henry Saputra <he...@gmail.com>.
Hi Kristian,

Could you post your code for "getMemberUsersRecordCount" ?

Maybe you have something like offset*AppConstants.PAGING_COUNT which makes
DataProvider.size() larger than actual data available.

- Henry

On Thu, Mar 4, 2010 at 1:49 AM, kristian_widjaja <
kristian_widjaja2@yahoo.com> wrote:

>
> Hi Bob,
>
> I was doing a litle magic and it fixed already, just did by setting the
> value of 'pageSize' property from click.Table the same as my own variable
> page size 'PAGING_COUNT'. It works fine now.
>
> But why is that the values of those variable has to be the same?
>
> Regards,
> Kristian W.
> --
> View this message in context:
> http://n2.nabble.com/Table-throws-exception-when-the-amount-of-retrieved-data-is-less-than-its-page-size-tp4672850p4673295.html
> Sent from the click-user mailing list archive at Nabble.com.
>

Re: Table throws exception when the amount of retrieved data is less than its page size

Posted by kristian_widjaja <kr...@yahoo.com>.
Hi Bob,

I was doing a litle magic and it fixed already, just did by setting the
value of 'pageSize' property from click.Table the same as my own variable
page size 'PAGING_COUNT'. It works fine now. 

But why is that the values of those variable has to be the same?

Regards,
Kristian W.
-- 
View this message in context: http://n2.nabble.com/Table-throws-exception-when-the-amount-of-retrieved-data-is-less-than-its-page-size-tp4672850p4673295.html
Sent from the click-user mailing list archive at Nabble.com.

Re: Table throws exception when the amount of retrieved data is less than its page size

Posted by Bob Schellink <sa...@gmail.com>.
The LargeDataSet demo DataProvider is a bit of a hack as it overrides the ArrayList size method to 
return a number much larger than the actual amount of rows. The #get method must then deduct the 
correct offset from the index to retrieve the correct record. If you debug the DataProvider #get and 
#size methods it should give insight as to what is happning.

kind regards

bob


On 4/03/2010 08:29 PM, kristian_widjaja wrote:
>
> Ok, thanks Bob. Well, there must be something wrong with code then. I'll try
> to fix it first.
>
> Regards,
> Kristian W.


Re: Table throws exception when the amount of retrieved data is less than its page size

Posted by kristian_widjaja <kr...@yahoo.com>.
Ok, thanks Bob. Well, there must be something wrong with code then. I'll try
to fix it first.

Regards,
Kristian W.
-- 
View this message in context: http://n2.nabble.com/Table-throws-exception-when-the-amount-of-retrieved-data-is-less-than-its-page-size-tp4672850p4673220.html
Sent from the click-user mailing list archive at Nabble.com.

Re: Table throws exception when the amount of retrieved data is less than its page size

Posted by Bob Schellink <sa...@gmail.com>.
Yep, I did the test with LargeDatasetDemo which has a pagesize of 5.

kind regards

bob

On 4/03/2010 08:09 PM, kristian_widjaja wrote:
>
> Hi, Bob and Malcolm. Thanks for replying.
>
> To Bob,
> Have you tried to set the pageSize larger than the actual amount of
> available data by using "DataProvider"? Cause the problem arise when that
> strategy is implemented.
>
> To Malcolm,
> I am using JDBC wrapped by iBatis. Method to retrieved the list of data is
> below :
>
> <code>
> private List<MemberUsers>  getMemberUsersList() {
> 		int offset = 1;
>
> 		if (StringUtils.hasLength(page)) {
> 			int pageNumber = Integer.parseInt(page);
> 			offset = pageNumber * AppConstants.PAGING_COUNT; // PAGING_COUNT = 10;
> 		}
>
> 		return memberUsersService.getUsersListByVirtualId(
> 				getPreservedState().toString(), offset, AppConstants.PAGING_COUNT);
> 	}
> </code>
>
>
> The query is listed below:
>
> <code>
> select USER_ID, VIRTUAL_ID, JOIN_DT, STATUS, NAME, BIRTH_DT, EMAIL, PHONE,
> UPLINE
>      from ( select a.USER_ID, a.VIRTUAL_ID, a.JOIN_DT, a.STATUS, a.NAME,
> a.BIRTH_DT, a.EMAIL,
>      			  a.PHONE, a.UPLINE, rownum rnum
>             from (
>             		select USER_ID, VIRTUAL_ID, JOIN_DT, STATUS, NAME, BIRTH_DT,
> EMAIL, PHONE, UPLINE
>      	 		from GNGUSER.MEMBER_USERS
>              ) a
>             where rownum<= #maxRows#
>           )
>      where rnum>= #minRows#
> </code>
>
> Anyway, as available records only 5 records currently, so when i set the
> 'pageSize = 5' and constant 'PAGING_COUNT = 5', it works well. As i
> mentioned before, only when i set 'pageSize' larger than actual available
> data count then the exception is thrown. Thanks.
>
> Regards,
> Kristian Widjaja.