You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by RonPiterman <rp...@gmx.net> on 2007/01/04 15:26:48 UTC

making links :visited across components

I have a nice usability problem with direct links nested inside components:

I have a pager component, which takes an in-out "page" parameter.

The pager component generates direct links, which invoke a listener in 
the component with the page number as parameter.

The listener calls the set method of the "page" parameter, thus changing 
the page number.

Now if I drop two instances of the pager component in a page, they both 
generate different links, so visited pages can not be traced:

if the user clicks "2" on the one pager, the url is:

http://localhost:8080/bardtke/reg/Forum,$Pager.$DirectLink_1.sdirect?sp=1

on the other pager, the url is:

http://localhost:8080/bardtke/reg/Forum,$Pager_0.$DirectLink_1.sdirect?sp=1



so if on pager 1 page 2 is marked as visited, on pager 1 it isn't :(

Now thats a fine problem...

Any idees ?

Cheers,

Ron


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: making links :visited across components

Posted by Dennis Sinelnikov <de...@augustschell.com>.
Thanks Ron.

Ron Piterman wrote:
> Dennis Sinelnikov wrote:
>> Ron,
>>
>> Since code speaks thousand words :), I would love to see some sample
>> code on what you're trying to do and how you did it.  If you're busy, no
>> biggie, just trying to learn a new pattern...
> 
> :) yes, I am busy.
> 
> I will try to demonstrate it:
> 
> ===============
> INSTEAD of implementing the pager like this:
> 
> <span jwcid="@For" ... value="ognl:currentPageNumber">
>   <a jwcid="@DirectLink" listener="listener:setPageNumber"
>       disabled="ognl:pageNumber == currentPageNumber"
>   >
>     <span jwcid="@Insert" value="ognl:currentPageNumber">
>     </span></a>
> </span>
> 
> and using it like:
> 
> <div jwcid="@Pager" pageNumber="ognl:pageNumber" itemsPerPage="ognl:10"
> itemCount="ognl:itemCount"></div>
> 
> ================
> THE NEW WAY is:
> 
> <span jwcid="@For" ... value="ognl:currentPageNumber">
>   <a jwcid="@DirectLink" listener="listener:setPageNumber"
>       disabled="ognl:pageNumber == currentPageNumber"
>   >
>   <span jwcid="@InvokeListener" listener="listener:updateOutParameters"
>     parameters="ognl: { currentPageNumberString , currentPageNumber }"
>   >
>   </span>
>   <span jwcid="@RenderBody"/>
> </span>
> 
> and using it:
> 
> <div jwcid="@Pager" pageNumber="ognl:pageNumber" itemsPerPage="ognl:10"
> itemCount="ognl:itemCount">
>   <span jwcid="@RenderBlock" block="component:pagerLinkBlock"></span>
> </div>
> 
> ...
> 
> <div jwcid="renderLinkBlock@Block">
>   <a jwcid="@DirectLink" listener="listener:setPageNumber"
>       disabled="ognl:linkSelected" parameters="ognl:linkPageNumber"
>   >
>     <span jwcid="@Insert" value="ognl:linkText">
>     </span></a>
> </div>
> 
> 
> to make this work I added to the pager:
> 
> @Parameter public abstract String getLinkText();
> @Parameter public abstract int getLinkPageNumber();
> @Parameter public abstract boolean isLinkSelected();
> 
> and
> 
> public void updateOutParameters(String text, int pageNum ) {
>   setLinkText( text );
>   setLinkPageNumber( pageNum );
>   setLinkSelected( pageNum == getPageNumber();
> }
> 
> Note that the pager does not only generate 1 2 3 links but also << and
>>> links to move forward and back, so i need the linkText and can not
> just use the page number as link text.
> 
> Further, an If was required inside the linkBlock because if the pageNum
> is 0, I need to generate another link which will be the default link to
> the page instead of a direct link, since page number 0 is probably
> visited once the page is first accessed...
> 
> so it is:
> 
> <div jwcid="renderLinkBlock@Block">
>   <span jwcid="@If" condition="ognl:linkPageNumber == 0">
>     ... generate a link to the page, which will be "visited" anywayz
>   </span>
>   <span jwcid="@Else">
> 
>     <a jwcid="@DirectLink" listener="listener:setPageNumber"
>         disabled="ognl:linkSelected" parameters="ognl:linkPageNumber"
>     >
>       <span jwcid="@Insert" value="ognl:linkText">
>       </span></a>
>   </span>
> </div>
> 
>> Thanks,
>> Dennis
>>
>> RonPiterman wrote:
>>> andyhot wrote:
>>>> Do you have to use direct links?
>>>> They expose too much of the inner workings of tapestry - that's why
>>>> they're not got for bookmarks as well...
>>> how is this possible if my component should be dropped in different
>>> pages ?
>>>
>>> I found finally another solution:
>>>
>>> What I did is removed the link rendering from the pager, and delegated
>>> it to its body.
>>>
>>> Added 3 out parameters: link text, link page and if selected.
>>>
>>> in the page I added as a body a renderBlog, in both pages the same
>>> block, which contains the desired link. So both pagers render the same
>>> link, thus do the same URls...
>>>
>>> Cheers,
>>> Ron
>>>
>>>
>>>> Anyway, can you code around this using ExternalLinks ?
>>>>
>>>>
>>>> RonPiterman wrote:
>>>>> I have a nice usability problem with direct links nested inside
>>>>> components:
>>>>>
>>>>> I have a pager component, which takes an in-out "page" parameter.
>>>>>
>>>>> The pager component generates direct links, which invoke a listener in
>>>>> the component with the page number as parameter.
>>>>>
>>>>> The listener calls the set method of the "page" parameter, thus
>>>>> changing the page number.
>>>>>
>>>>> Now if I drop two instances of the pager component in a page, they
>>>>> both generate different links, so visited pages can not be traced:
>>>>>
>>>>> if the user clicks "2" on the one pager, the url is:
>>>>>
>>>>> http://localhost:8080/bardtke/reg/Forum,$Pager.$DirectLink_1.sdirect?sp=1
>>>>>
>>>>>
>>>>> on the other pager, the url is:
>>>>>
>>>>> http://localhost:8080/bardtke/reg/Forum,$Pager_0.$DirectLink_1.sdirect?sp=1
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> so if on pager 1 page 2 is marked as visited, on pager 1 it isn't :(
>>>>>
>>>>> Now thats a fine problem...
>>>>>
>>>>> Any idees ?
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Ron
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: making links :visited across components

Posted by Ron Piterman <rp...@gmx.net>.
Dennis Sinelnikov wrote:
> Ron,
> 
> Since code speaks thousand words :), I would love to see some sample
> code on what you're trying to do and how you did it.  If you're busy, no
> biggie, just trying to learn a new pattern...

:) yes, I am busy.

I will try to demonstrate it:

===============
INSTEAD of implementing the pager like this:

<span jwcid="@For" ... value="ognl:currentPageNumber">
  <a jwcid="@DirectLink" listener="listener:setPageNumber"
      disabled="ognl:pageNumber == currentPageNumber"
  >
    <span jwcid="@Insert" value="ognl:currentPageNumber">
    </span></a>
</span>

and using it like:

<div jwcid="@Pager" pageNumber="ognl:pageNumber" itemsPerPage="ognl:10"
itemCount="ognl:itemCount"></div>

================
THE NEW WAY is:

<span jwcid="@For" ... value="ognl:currentPageNumber">
  <a jwcid="@DirectLink" listener="listener:setPageNumber"
      disabled="ognl:pageNumber == currentPageNumber"
  >
  <span jwcid="@InvokeListener" listener="listener:updateOutParameters"
    parameters="ognl: { currentPageNumberString , currentPageNumber }"
  >
  </span>
  <span jwcid="@RenderBody"/>
</span>

and using it:

<div jwcid="@Pager" pageNumber="ognl:pageNumber" itemsPerPage="ognl:10"
itemCount="ognl:itemCount">
  <span jwcid="@RenderBlock" block="component:pagerLinkBlock"></span>
</div>

...

<div jwcid="renderLinkBlock@Block">
  <a jwcid="@DirectLink" listener="listener:setPageNumber"
      disabled="ognl:linkSelected" parameters="ognl:linkPageNumber"
  >
    <span jwcid="@Insert" value="ognl:linkText">
    </span></a>
</div>


to make this work I added to the pager:

@Parameter public abstract String getLinkText();
@Parameter public abstract int getLinkPageNumber();
@Parameter public abstract boolean isLinkSelected();

and

public void updateOutParameters(String text, int pageNum ) {
  setLinkText( text );
  setLinkPageNumber( pageNum );
  setLinkSelected( pageNum == getPageNumber();
}

Note that the pager does not only generate 1 2 3 links but also << and
>> links to move forward and back, so i need the linkText and can not
just use the page number as link text.

Further, an If was required inside the linkBlock because if the pageNum
is 0, I need to generate another link which will be the default link to
the page instead of a direct link, since page number 0 is probably
visited once the page is first accessed...

so it is:

<div jwcid="renderLinkBlock@Block">
  <span jwcid="@If" condition="ognl:linkPageNumber == 0">
    ... generate a link to the page, which will be "visited" anywayz
  </span>
  <span jwcid="@Else">

    <a jwcid="@DirectLink" listener="listener:setPageNumber"
        disabled="ognl:linkSelected" parameters="ognl:linkPageNumber"
    >
      <span jwcid="@Insert" value="ognl:linkText">
      </span></a>
  </span>
</div>

> 
> Thanks,
> Dennis
> 
> RonPiterman wrote:
>> andyhot wrote:
>>> Do you have to use direct links?
>>> They expose too much of the inner workings of tapestry - that's why
>>> they're not got for bookmarks as well...
>>
>> how is this possible if my component should be dropped in different
>> pages ?
>>
>> I found finally another solution:
>>
>> What I did is removed the link rendering from the pager, and delegated
>> it to its body.
>>
>> Added 3 out parameters: link text, link page and if selected.
>>
>> in the page I added as a body a renderBlog, in both pages the same
>> block, which contains the desired link. So both pagers render the same
>> link, thus do the same URls...
>>
>> Cheers,
>> Ron
>>
>>
>>>
>>> Anyway, can you code around this using ExternalLinks ?
>>>
>>>
>>> RonPiterman wrote:
>>>> I have a nice usability problem with direct links nested inside
>>>> components:
>>>>
>>>> I have a pager component, which takes an in-out "page" parameter.
>>>>
>>>> The pager component generates direct links, which invoke a listener in
>>>> the component with the page number as parameter.
>>>>
>>>> The listener calls the set method of the "page" parameter, thus
>>>> changing the page number.
>>>>
>>>> Now if I drop two instances of the pager component in a page, they
>>>> both generate different links, so visited pages can not be traced:
>>>>
>>>> if the user clicks "2" on the one pager, the url is:
>>>>
>>>> http://localhost:8080/bardtke/reg/Forum,$Pager.$DirectLink_1.sdirect?sp=1
>>>>
>>>>
>>>> on the other pager, the url is:
>>>>
>>>> http://localhost:8080/bardtke/reg/Forum,$Pager_0.$DirectLink_1.sdirect?sp=1
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> so if on pager 1 page 2 is marked as visited, on pager 1 it isn't :(
>>>>
>>>> Now thats a fine problem...
>>>>
>>>> Any idees ?
>>>>
>>>> Cheers,
>>>>
>>>> Ron
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: making links :visited across components

Posted by Dennis Sinelnikov <de...@augustschell.com>.
Ron,

Since code speaks thousand words :), I would love to see some sample 
code on what you're trying to do and how you did it.  If you're busy, no 
biggie, just trying to learn a new pattern...

Thanks,
Dennis

RonPiterman wrote:
> andyhot wrote:
>> Do you have to use direct links?
>> They expose too much of the inner workings of tapestry - that's why
>> they're not got for bookmarks as well...
> 
> how is this possible if my component should be dropped in different pages ?
> 
> I found finally another solution:
> 
> What I did is removed the link rendering from the pager, and delegated 
> it to its body.
> 
> Added 3 out parameters: link text, link page and if selected.
> 
> in the page I added as a body a renderBlog, in both pages the same 
> block, which contains the desired link. So both pagers render the same 
> link, thus do the same URls...
> 
> Cheers,
> Ron
> 
> 
>>
>> Anyway, can you code around this using ExternalLinks ?
>>
>>
>> RonPiterman wrote:
>>> I have a nice usability problem with direct links nested inside
>>> components:
>>>
>>> I have a pager component, which takes an in-out "page" parameter.
>>>
>>> The pager component generates direct links, which invoke a listener in
>>> the component with the page number as parameter.
>>>
>>> The listener calls the set method of the "page" parameter, thus
>>> changing the page number.
>>>
>>> Now if I drop two instances of the pager component in a page, they
>>> both generate different links, so visited pages can not be traced:
>>>
>>> if the user clicks "2" on the one pager, the url is:
>>>
>>> http://localhost:8080/bardtke/reg/Forum,$Pager.$DirectLink_1.sdirect?sp=1 
>>>
>>>
>>> on the other pager, the url is:
>>>
>>> http://localhost:8080/bardtke/reg/Forum,$Pager_0.$DirectLink_1.sdirect?sp=1 
>>>
>>>
>>>
>>>
>>>
>>> so if on pager 1 page 2 is marked as visited, on pager 1 it isn't :(
>>>
>>> Now thats a fine problem...
>>>
>>> Any idees ?
>>>
>>> Cheers,
>>>
>>> Ron
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: making links :visited across components

Posted by RonPiterman <rp...@gmx.net>.
andyhot wrote:
> Do you have to use direct links?
> They expose too much of the inner workings of tapestry - that's why
> they're not got for bookmarks as well...

how is this possible if my component should be dropped in different pages ?

I found finally another solution:

What I did is removed the link rendering from the pager, and delegated 
it to its body.

Added 3 out parameters: link text, link page and if selected.

in the page I added as a body a renderBlog, in both pages the same 
block, which contains the desired link. So both pagers render the same 
link, thus do the same URls...

Cheers,
Ron


> 
> Anyway, can you code around this using ExternalLinks ?
> 
> 
> RonPiterman wrote:
>> I have a nice usability problem with direct links nested inside
>> components:
>>
>> I have a pager component, which takes an in-out "page" parameter.
>>
>> The pager component generates direct links, which invoke a listener in
>> the component with the page number as parameter.
>>
>> The listener calls the set method of the "page" parameter, thus
>> changing the page number.
>>
>> Now if I drop two instances of the pager component in a page, they
>> both generate different links, so visited pages can not be traced:
>>
>> if the user clicks "2" on the one pager, the url is:
>>
>> http://localhost:8080/bardtke/reg/Forum,$Pager.$DirectLink_1.sdirect?sp=1
>>
>> on the other pager, the url is:
>>
>> http://localhost:8080/bardtke/reg/Forum,$Pager_0.$DirectLink_1.sdirect?sp=1
>>
>>
>>
>>
>> so if on pager 1 page 2 is marked as visited, on pager 1 it isn't :(
>>
>> Now thats a fine problem...
>>
>> Any idees ?
>>
>> Cheers,
>>
>> Ron
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: making links :visited across components

Posted by andyhot <an...@di.uoa.gr>.
Do you have to use direct links?
They expose too much of the inner workings of tapestry - that's why
they're not got for bookmarks as well...

Anyway, can you code around this using ExternalLinks ?


RonPiterman wrote:
> I have a nice usability problem with direct links nested inside
> components:
>
> I have a pager component, which takes an in-out "page" parameter.
>
> The pager component generates direct links, which invoke a listener in
> the component with the page number as parameter.
>
> The listener calls the set method of the "page" parameter, thus
> changing the page number.
>
> Now if I drop two instances of the pager component in a page, they
> both generate different links, so visited pages can not be traced:
>
> if the user clicks "2" on the one pager, the url is:
>
> http://localhost:8080/bardtke/reg/Forum,$Pager.$DirectLink_1.sdirect?sp=1
>
> on the other pager, the url is:
>
> http://localhost:8080/bardtke/reg/Forum,$Pager_0.$DirectLink_1.sdirect?sp=1
>
>
>
>
> so if on pager 1 page 2 is marked as visited, on pager 1 it isn't :(
>
> Now thats a fine problem...
>
> Any idees ?
>
> Cheers,
>
> Ron
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / J2EE Consulting 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org