Oleg,

(Yes, I know this is an old post, I'm replying to - work is getting in the
way these days. ;-) )

I guess I need some help in understanding how this works. Could you give a
brief description of the ideas behind the tag? What objects are being
created where, and being used how? What would my action have to do, and what
would my JSP page look like, if I needed to be able to page through a
(possibly huge) list from a database?

It seems to me, from some of the attribute names you have defined, that it
might be simpler to define a class which represents the "chunk" of data you
are currently presenting relative to the total being paged through. This
class would then handle things like the count for this chunk, the total
size, etc. An instance of this class would be stored by the action, either
in a form bean or in the request or session, and referenced from the pager
tag and navigation tags. Doing this would avoid having to use the
<bean:define> tag to obtain the data from the form and pass it to the other
tags.

We have done something along these lines. It's not perfect, but it's fairly
straighforward to use in the JSP. Having the class representing the chunk
means that navigation tags can access it via the pager tag itself, and the
JSP page doesn't have to know.

--
Martin Cooper


----- Original Message -----
From: "Oleg V Alexeev" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 15, 2001 2:11 PM
Subject: PROPOSAL - <logic:pager> tag


> Hello struts-dev,
>
>   I create <logic:pager> tag handler to simplify page by page data
>   displaying.
>
>   Here is short description and sample of use.
>
> <taglib>
>     <tlibversion>1.0</tlibversion>
>     <jspversion>1.1</jspversion>
>     <shortname>logic</shortname>
>     <uri>http://jakarta.apache.org/struts/tags-logic-1.0</uri>
>     <tag>
>         <name>pager</name>
>         <tagclass>org.apache.struts.taglib.logic.PagerTag</tagclass>
>         <bodycontent>JSP</bodycontent>
>  <!-- Name to be used in page to refer to this Pager-->
>         <attribute>
>             <name>id</name>
>             <required>true</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>  <!-- Name to store Pager tag body in page scope variable - call Pager
>       once, save result and display it in page at any point. -->
>         <attribute>
>             <name>resultId</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>  <!-- Type of labels - page numbers or row ranges. -->
>         <attribute>
>             <name>labelType</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>  <!-- Class to use as backend Pager support -->
>         <attribute>
>             <name>type</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>  <!-- Show or not pager in place. Useful to generate pager and show it
>       multiple times. -->
>         <attribute>
>             <name>show</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>  <!-- Name of the page scope variable (Integer) with offset of the
>       first row.-->
>         <attribute>
>             <name>offset</name>
>             <required>true</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>  <!-- Length of the page. -->
>         <attribute>
>             <name>pageSize</name>
>             <required>true</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>  <!-- Total length of the list. -->
>         <attribute>
>             <name>totalSize</name>
>             <required>true</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>  <!-- Name for the paramater name (in URL) to be used as page size.
>       -->
>         <attribute>
>             <name>pageSizeName</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>  <!-- Name for the paramater name (in URL) to be used as offset.
>       -->
>         <attribute>
>             <name>offsetName</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>     </tag>
> </taglib>
>
> Sample of JSP page with pager tag -
>
> <bean:define id="offset" name="newsSlide" property="offset"
>                type="java.lang.Integer"/>
> <bean:define id="pageSize" name="newsSlide" property="slideLength"
>                type="java.lang.Integer"/>
> <bean:define id="totalSize" name="newsSlide" property="totalLength"
>                type="java.lang.Integer"/>
>
> <logicext:pager id="pager" resultId="pagerPanel"
>    show="false" offset="offset" pageSize="pageSize"
>    totalSize="totalSize">
>  <logic:greaterThan name="pager" property="pagesTotal" value="1">
>   <table>
>    <tr>
>     <td>
>      <logic:equal value="true" property="hasPrev" name="pager">
>       <html:link property="prev.link" name="pager"
forward="news">Prev</html:link>
>      </logic:equal>
>      <logic:equal value="false" property="hasPrev"
name="pager">Prev</logic:equal>
>     </td>
>      <logic:iterate property="linksIterator" name="pager" id="pagerItem">
>       <td>
>        <logic:equal value="false" property="isCurrent" name="pagerItem">
>         <html:link property="link" name="pagerItem" forward="news">
>          <bean:write property="label" name="pagerItem"/>
>         </html:link>
>        </logic:equal>
>        <logic:equal value="true" property="isCurrent" name="pagerItem">
>         <bean:write property="label" name="pagerItem"/>
>        </logic:equal>
>       </td>
>      </logic:iterate>
>     <td>
>      <logic:equal value="true" property="hasNext" name="pager">
>       <html:link property="next.link" name="pager"
forward="news">Next</html:link>
>      </logic:equal>
>      <logic:equal value="false" property="hasNext"
name="pager">Next</logic:equal>
>     </td>
>    </tr>
>   </table>
>  </logic:greaterThan>
> </logicext:pager>
>
> <bean:write name="pagerPanel" filter="false"/>
>
> .... page of the list
>
> <bean:write name="pagerPanel" filter="false"/>
>
> --
> Best regards,
>  Oleg                          mailto:[EMAIL PROTECTED]
>
>


Reply via email to