Hello Martin,
Thursday, June 28, 2001, 6:08:40 AM, you wrote:
MC> Oleg,
MC> (Yes, I know this is an old post, I'm replying to - work is getting in the
MC> way these days. ;-) )
MC> I guess I need some help in understanding how this works. Could you give a
MC> brief description of the ideas behind the tag?
Action or ActionServlet itself (with help of bean-factory)
1. creates instance of ArrayList (filled with data beans from
database) or CachedRowSet (populated from result set) - it uses
'offset' and 'pageSize' request parameters of form attributes to
retrieve rows from result set from 'offset' and length of 'pageSize'.
2. wrap it with Slide class object (contains fields 'offset',
'pageSize' and 'totalSize' to use it with Pager class)
3. store Slide in request or in session scope
At jsp page three bean:define tags are used to define 'offset',
'pageSize' and 'totalSize' as page scope variables (Integer) under
appropriate names.
<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"/>
(May be this is dummy overhead, of course... But I pass one object
only to the target scope - my idea was that it is more reliable. May
be it is wrong - your words force me to doubt about it.)
PagerTag in jsp-page uses this variables ('offset' and blah, blah,
blah...) to create, instantiate and register Pager in page scope
inside of PagerTag body.
<logicext:pager id="pager" resultId="pagerPanel"
show="false" offset="offset" pageSize="pageSize"
totalSize="totalSize">
</logicext:pager>
Inside of pager tag body we can refer to the pager object by name from
'id' attribute and use standart struts tags - bean:write and
logic:iterate to display info from pager tag.
For example, Pager contains property 'linksIterator' to access
iterator via links to the pages -
<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>
Each link is PagerEntry class object and contains two properties -
'label' (String) and 'link' (Map to generate parameters to call some
page). And more - we can use 'properties' attribute in PagerTag to
specify page scope bean (Map) with parameters to pass it to each link,
generated by Pager.
Result of PagerTag processing can be hidden by setting attribute
'show' to false and we can specify attribute 'resultId' to store this
result in page scope as String and show it multiple times later.
--
Best regards,
Oleg mailto:[EMAIL PROTECTED]