ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sabyasachi Biswas <biswas.sabyasa...@gmail.com>
Subject Re: Paginated List Problem in Ibatis
Date Thu, 27 Oct 2005 05:49:12 GMT
Hi Larry,
 Thank You for your response.
 I have a instance variable Paginated List , that all my methods use . There
are a large number of methods that use this Paginated List object.
I had thought it would not be feasible by making so many objects of The
Paginated List in each of my methods.
 Anyways, if I use different Paginated List objects in all my methods, the
concurrency issue remains, because the DAO keeps the Paginated List objects,
for iterating (nextPage(), firstPage()).
 Following is My Code sample:
  private PaginatedList pagList =null;
 private Double totalPages=null;
private int currentPage=0;
private double totalRecords=0;
private int totalPagesnum=0;
private int isFirstPage=0;
private int isLastPage=0;
private int iTotalRecords=0;
private double doubleTotalPages=0;
 /** @param pagingActivity To determine the condition of Paginated
List(start,back,next)
 @param pageNumber To detremine the page number selected
*/

public List getAllRequests(String pagingActivity,int pageNumber,Long
sDeskIdLng) throws DaoException
{
List viewAllVO = null;
try
{
AllServiceDeskVO alSDVo=new AllServiceDeskVO();
alSDVo.setServiceDeskId(sDeskIdLng);

// when the page is first requested
if(pagingActivity.equalsIgnoreCase("start"))
{

currentPage = 1;
SqlMapExecutor sqlMap = this.getSqlMapExecutor();
viewAllVO= sqlMap.queryForList("getAllRequests",alSDVo);
totalRecords = viewAllVO.size();
iTotalRecords = viewAllVO.size();
doubleTotalPages = (totalRecords / Constants.RESULTS_PER_PAGE);
totalPagesnum = Math.abs(iTotalRecords / Constants.RESULTS_PER_PAGE);
if (doubleTotalPages > totalPagesnum)
{
totalPagesnum++;
}
pagList = (PaginatedList)sqlMap.queryForPaginatedList("getAllRequests",
alSDVo, Constants.RESULTS_PER_PAGE);
}

else if(pagingActivity.equalsIgnoreCase("next"))
{
currentPage++;
pagList.nextPage();

}
else if(pagingActivity.equalsIgnoreCase("back"))
{
currentPage--;
pagList.previousPage();

}
else if(pagingActivity.equalsIgnoreCase("page"))
{
pagList.gotoPage(pageNumber-1);
currentPage = pageNumber;
}

if(pagList.isLastPage())
{
isLastPage=1;
}
else
{
isLastPage=0;
}
if(pagList.isFirstPage())
{
isFirstPage=1;
}
else
{
isFirstPage=0;
}

viewAllVO = new ArrayList();

Iterator listIterator = pagList.iterator();
while (listIterator.hasNext())
{
viewAllVO.add((ViewAllRequestsVO)listIterator.next());
}

int recNum = 0;
for(int i=0; i<viewAllVO.size(); i++)
{
ViewAllRequestsVO viewVO = (ViewAllRequestsVO)viewAllVO.get(i);
viewVO.setIsLastPage(isLastPage);
viewVO.setIsFirstPage(isFirstPage);
viewVO.setTotalPages(totalPagesnum);
viewVO.setCurrentPage(currentPage);
recNum = ( (currentPage-1) * VantageConstants.RESULTS_PER_PAGE ) + i + 1;
viewVO.setRecordNumber(recNum);
viewVO.setStrDate(DateUtil.displayDate(viewVO.getDate()));
}


}
catch (Exception e)
{
e.printStackTrace();
throw new DaoException();
}
return viewAllVO;
}
There are number of methods that are performed the same way.
 Thanks in advance,
 Sabyasachi Biswas.

 On 10/24/05, Larry Meadors <lmeadors@apache.org> wrote:
>
> Why do you "have to use only one object of Paginated List"?
>
> You can use as many as you want. It sounds like your dao is storing
> the paginated list..that would be a really bad idea.
>
> Maybe you can explain what you are trying to do in more detail...
>
> Larry
>
> On 10/24/05, Sabyasachi Biswas <biswas.sabyasachi@gmail.com> wrote:
> > Hi all,
> >
> > I am having a problem using paginated List in my Project.
> >
> > I am using the same Paginated List object for various purposes(I have to
> use
> > only one object of Paginated List). The problem arises when there are
> > concurrent users , the Paginated List Object returned should be
> different
> > for different criteria as requested by the user.
> >
> > But, this does not happen as, Ibatis uses the same DAO Implementation
> > object.
> >
> > For eg:
> > I have a search page which searches the number of user on the basis of
> > roles.
> >
> >
> > I have another search page which searches the number of user on the
> basis
> > of departments.
> >
> > When User1 searches on the basis of roles he gets a paginated list.
> >
> > When User2 searches on the basis of departments he gets a paginated list
> .
> >
> > Now when User 1 iterates over the paginated list he gets the results of
> User
> > 2.
> >
> > Please help me with your suggestions.
> >
> > Thanks in advance,
> >
> > Regards,
> >
> > Sabyasachi Biswas.
>

Mime
View raw message