You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by jalal udeen <ja...@gmail.com> on 2007/05/08 14:27:45 UTC

pagination problem pls rectify this error its very urgent for me

hi  all


I have to use pagination in jsp  so i did it with logic:iterate  tag as
follows

i use  2 links   next and previous  in this application

but next link is not disapppearinng when it reaches the last record pls
check the condition and clear my doubt this  pls its very urgent for me

the code follows


<%
  String strOffset ="0";
    if(request.getParameter("pagination")!=null)
     strOffset=request.getParameter("pagination");
     else
    strOffset ="0";
    String strLength = "2";
    int increment = Integer.parseInt(strOffset) + Integer.parseInt(strLength)
;
    String strIncOffset = String.valueOf(increment);
      ArrayList list  =(ArrayList)request.getAttribute("pattern");
 int size= list.size();

    if((Integer.parseInt(strIncOffset)>= size))
     strIncOffset ="0";

%>

*Logic tags*

<logic:iterate id="user" name="pattern" scope="request" type="
com.pa.pattern.helper.Helper" offset="<%=strOffset%>"
length="<%=strLength%>">

* Links*



*Next Link:*

**



     </tr>
<%


if(Integer.parseInt(strOffset)!=size &&  !((Integer.parseInt(strOffset)>size)
) && !(Integer.parseInt(strLength)>=size) )

{


%>
<table align="right">
 <TR><TD ALIGN=""><a href="viewpattern.do?pagination=<%=strIncOffset%>"
>Next</a></TD>
<%
}

%>





*prev Link*

**

<%


if((strIncOffset.trim().equals(String.valueOf(size)) ||
Integer.parseInt(strOffset)
>0   ) && !(Integer.parseInt(strLength)>=size))
{
 strIncOffset=String.valueOf(Integer.parseInt(strOffset)-2);

%>

<TD><a href="viewpattern.do?pagination=<%=strIncOffset%>"
>Prev</a></td></tr>
<%
}%>



pls i need a help for this



thanks

jalaludeen

but next link is not disspearinng when it reaces the last one can any help
me for this

the code follows


<%
  String strOffset ="0";
    if(request.getParameter("pagination")!=null)
     strOffset=request.getParameter("pagination");
     else
    strOffset ="0";
    String strLength = "2";
    int increment = Integer.parseInt(strOffset) + Integer.parseInt(strLength)
;
    String strIncOffset = String.valueOf(increment);
      ArrayList list  =(ArrayList)request.getAttribute("pattern");
 int size= list.size();

    if((Integer.parseInt(strIncOffset)>= size))
     strIncOffset ="0";

%>

*Logic tags*

<logic:iterate id="user" name="pattern" scope="request" type="
com.pa.pattern.helper.Helper" offset="<%=strOffset%>"
length="<%=strLength%>">

* Links*



*Next Link:*

**



     </tr>
<%


if(Integer.parseInt(strOffset)!=size &&  !((Integer.parseInt(strOffset)>size)
) && !( Integer.parseInt(strLength)>=size) )

{


%>
<table align="right">
 <TR><TD ALIGN=""><a href="viewpattern.do?pagination=<%=strIncOffset%>"
>Next</a></TD>
<%
}

%>





*prev Link*

**

<%


if((strIncOffset.trim().equals(String.valueOf(size)) ||
Integer.parseInt(strOffset)
>0   ) && !(Integer.parseInt(strLength)>=size))
{
 strIncOffset=String.valueOf(Integer.parseInt(strOffset)-2);

%>

<TD><a href="viewpattern.do?pagination=<%=strIncOffset%>"
>Prev</a></td></tr>
<%
}%>



pls i need a help for this   pls rectify this error its very urgent for me



thanks

jalaludeen

[OT] Re: pagination problem pls rectify this error its very urgent for me

Posted by Dave Newton <ne...@yahoo.com>.
--- jalal udeen <ja...@gmail.com> wrote:
> I have to use pagination in jsp  so i did it with
> logic:iterate  tag as follows

One reason you may not be getting an answer is that
this has nothing to do with Struts.

> <%
>   String strOffset ="0";
>     if(request.getParameter("pagination")!=null)
>      strOffset=request.getParameter("pagination");
>      else
>     strOffset ="0";
>     String strLength = "2";
>     int increment = Integer.parseInt(strOffset) +
> Integer.parseInt(strLength)
> ;
>     String strIncOffset = String.valueOf(increment);
>       ArrayList list 
> =(ArrayList)request.getAttribute("pattern");
>  int size= list.size();
> 
>     if((Integer.parseInt(strIncOffset)>= size))
>      strIncOffset ="0";
> 
> %>

(The following is my opinion and probably does not
reflect the views of the rest of the Struts mailing
list.)

I started to look at the code, but it was too weird
for me--it would not have survived even the most
cursory of code reviews. That made me even less likely
to want to answer the question.

What I would suggest doing (besides cleaning up the
code) is, on paper, write down a few test cases,
focusing on the edge case which is giving you problems
at the moment.

Build a truth table using your values and the logical
conditions you have and see why they might be failing.
If I don't have anything else to do at work today
perhaps I'll suck it up and take another look at it
and you can buy me a Kingfisher.

d.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org