You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Denis Ponomarev <oz...@romsat.ua> on 2003/06/24 14:14:07 UTC
Re[2]: Service parameters
RD> My initial attempt was using persistent properties. However, I was
RD> unable to set a persistent property while rendering. And the value of
RD> the persistent property depends on the result of the query that is
RD> executed in the prepareForRender... (The property must be changed (only)
RD> if the number of result elements is less than a certain value, so it
RD> should be persistent).
You can implement PageRenderListener interface in your component.
It contains of two method, one can be usefull:
public void pageBeginRender(PageEvent event) {
// here is your final chance to change persistent properties
// probably this is the place where you should execute query
// and correct persistent property depending on query result
}
>> Look:
>>
>> <component name="prevLink" type="DirectLink">
>> <binding name="listener" expression="listeners.changePage"/>
>> <binding name="parameters" expression="prevPage"/>
>> <binding name="disabled" expression="first"/>
>> </component>
>>
>> <component name="nextLink" type="DirectLink">
>> <binding name="listener" expression="listeners.changePage"/>
>> <binding name="parameters" expression="nextPage"/>
>> <binding name="disabled" expression="last"/>
>> </component>
>>
>> It assumes that your table component has isFirst(), isLast(),
>> getNext() and getPrevious() methods based on the currentPage
>> persistent property.
>>
>> And action listener method
>>
>> public void changePage(IRequestCycle cycle){
>> Integer pageNumber = (Integer) cycle.getServiceParameters()[0];
>> setCurrentPage(pageNumber.intValue());
>> }
>>
>> RD> the extra burden on the template author, who has to specify the
>> RD> parameter on each DirectLink tag.
>>
>> Template author just locates components:
>>
>> <a jwcid="prevLink">previous</a> <a jwcid="nextLink">next</a>
>>
>> There is no parameters specification!
>>
RD> I tend to specify the links directly in the html templates using
RD> jwcid="@DirectLink". I agree that using the jwc file to specify
RD> parameters is more puristic.
RD> However, I have a dynamic set of links, one for each page (like google)
RD> of a data set. I have no choice then but to put them directly in the
RD> html template:
RD> <span jwcid="@Foreach" value="ognl:navigationPage"
RD> source="ognl:navigationPages">
RD> <a jwcid="@DirectLink" listener="ognl:listeners.changePage"
RD> parameters="ognl:navigationPage">
RD> <span jwcid="@Insert" value="ognl:navigationPage + 1"/>
RD> </a>
RD> </span>
I think it can be implemented:
====================
<component id="everyPage" value="ognl:navigationPage">
<binding name="source" expression="navigationPages"/>
<binding name="value" expression="navigationPage"/>
</component>
<component name="pageLink" type="DirectLink">
<binding name="listener" expression="listeners.changePage"/>
<binding name="parameters" expression="navigationPage"/>
<binding name="disabled" expression="current"/>
</component>
<component name="pageIndex" type="Insert">
<binding name="value" expression="navigationPage"/>
</component>
====================
<span jwcid="everyPage">
<a jwcid="pageLink"><span jwcid="pageIndex"/></a>
</span>
====================
RE: Re[2]: Service parameters
Posted by Ruud Diterwich <rd...@cedron.com>.
Thanks a lot! Very useful.
Ruud
> -----Original Message-----
> From: Denis Ponomarev [mailto:oz@romsat.ua]
> Sent: Tuesday, June 24, 2003 14:14
> To: Tapestry users
> Subject: Re[2]: Service parameters
>
> RD> My initial attempt was using persistent properties. However, I was
> RD> unable to set a persistent property while rendering. And the value
of
> RD> the persistent property depends on the result of the query that is
> RD> executed in the prepareForRender... (The property must be changed
> (only)
> RD> if the number of result elements is less than a certain value, so
it
> RD> should be persistent).
>
> You can implement PageRenderListener interface in your component.
> It contains of two method, one can be usefull:
>
> public void pageBeginRender(PageEvent event) {
> // here is your final chance to change persistent properties
> // probably this is the place where you should execute query
> // and correct persistent property depending on query result
> }
>
> >> Look:
> >>
> >> <component name="prevLink" type="DirectLink">
> >> <binding name="listener" expression="listeners.changePage"/>
> >> <binding name="parameters" expression="prevPage"/>
> >> <binding name="disabled" expression="first"/>
> >> </component>
> >>
> >> <component name="nextLink" type="DirectLink">
> >> <binding name="listener" expression="listeners.changePage"/>
> >> <binding name="parameters" expression="nextPage"/>
> >> <binding name="disabled" expression="last"/>
> >> </component>
> >>
> >> It assumes that your table component has isFirst(), isLast(),
> >> getNext() and getPrevious() methods based on the currentPage
> >> persistent property.
> >>
> >> And action listener method
> >>
> >> public void changePage(IRequestCycle cycle){
> >> Integer pageNumber = (Integer)
cycle.getServiceParameters()[0];
> >> setCurrentPage(pageNumber.intValue());
> >> }
> >>
> >> RD> the extra burden on the template author, who has to specify the
> >> RD> parameter on each DirectLink tag.
> >>
> >> Template author just locates components:
> >>
> >> <a jwcid="prevLink">previous</a> <a jwcid="nextLink">next</a>
> >>
> >> There is no parameters specification!
> >>
>
> RD> I tend to specify the links directly in the html templates using
> RD> jwcid="@DirectLink". I agree that using the jwc file to specify
> RD> parameters is more puristic.
>
> RD> However, I have a dynamic set of links, one for each page (like
> google)
> RD> of a data set. I have no choice then but to put them directly in
the
> RD> html template:
>
> RD> <span jwcid="@Foreach" value="ognl:navigationPage"
> RD> source="ognl:navigationPages">
>
> RD> <a jwcid="@DirectLink"
listener="ognl:listeners.changePage"
> RD> parameters="ognl:navigationPage">
> RD> <span jwcid="@Insert" value="ognl:navigationPage +
> 1"/>
> RD> </a>
> RD> </span>
>
>
> I think it can be implemented:
> ====================
>
> <component id="everyPage" value="ognl:navigationPage">
> <binding name="source" expression="navigationPages"/>
> <binding name="value" expression="navigationPage"/>
> </component>
>
> <component name="pageLink" type="DirectLink">
> <binding name="listener" expression="listeners.changePage"/>
> <binding name="parameters" expression="navigationPage"/>
> <binding name="disabled" expression="current"/>
> </component>
>
> <component name="pageIndex" type="Insert">
> <binding name="value" expression="navigationPage"/>
> </component>
>
> ====================
>
> <span jwcid="everyPage">
> <a jwcid="pageLink"><span jwcid="pageIndex"/></a>
> </span>
>
> ====================
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org