You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jan Vissers <Ja...@cumquat.nl> on 2008/04/23 17:19:24 UTC

My breadcrumb component from T4 to T5

Hi,

Need some advice. In T4 I had a breadcrumb component that got its
information from a breadcrumb model structure. Each page that needed to go
onto the crumb path would implement some base page class. This page class
implemented PageRenderListener and IExternalPage. The former to add info
to the model and the latter to remove info from the model (btw the
breadcrumb model was an ASO).

Basically the model consisted of some key, name/title and (constructed)
link tuple. The link basically pointed to an IExternalPage implemented
page class - so to be precise the whole breadcrumb path consisted of
bookmarkable pages.

I'm trying to mimic this behavior with T5, using the BeginRender
annotation on a basepage class method called initPage() and also on the
basepage class a onActivate() method. I have some questions about it.
Below the specific base page code:

    protected String getBreadCrumbTitle() {
        return resources.getMessages().get("title-" +
           resources.getPageName().toLowerCase());
    }

    protected Object[] getLinkParameters() {
        return null;
    }

    @BeginRender
    public void initPage() {
        String pageName = resources.getPageName();
        Link link = resources.createPageLink(resources.getPageName(),
              true, getLinkParameters());
        breadCrumbHolder.checkBreadCrumbForAdd(pageName,
              getBreadCrumbTitle(), link.toRedirectURI());
    }

    public void onActivate() {
        String pageName = resources.getPageName();
        breadCrumbHolder.checkBreadCrumbForRemove(pageName);
    }

Q1: the initPage() method is there to create a 'bookmarkable' link -
amongst others - and store that information in the breadcrumb model. The
getLinkParameters() is there for a subclass to provide its specific
activation parameters to be used. Should I use another way to create
bookmarable links?

Q2: the onActivate() method is there to remove one (or more) crumbs from
the crumbpath. Since other pages will also need activation - potentially
with additional arguments - is this onActivate() the best way/place to
manipulate the model? I'm getting the idea that onActivate() is not the
designated alternative for T4's activateExternalPage(Object[] parameters,
IRequestCycle cycle) in IExternalPage interface.

Currently all of this works - although haven't tested activation with
activation context parameters yet.

Thx.
-J.


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


Re: My breadcrumb component from T4 to T5

Posted by Josh Canfield <jo...@thedailytube.com>.
I used T4 for a short period a long time ago, so I'm not understanding
the parallels that you are making. Can you describe the workflow that
you are shooting for? I'm not clear why you'd remove the breadcrumb in
the activate event and the add it again the beginrender event.


Josh

On Wed, Apr 23, 2008 at 8:19 AM, Jan Vissers <Ja...@cumquat.nl> wrote:
> Hi,
>
> Need some advice. In T4 I had a breadcrumb component that got its
> information from a breadcrumb model structure. Each page that needed to go
> onto the crumb path would implement some base page class. This page class
> implemented PageRenderListener and IExternalPage. The former to add info
> to the model and the latter to remove info from the model (btw the
> breadcrumb model was an ASO).
>
> Basically the model consisted of some key, name/title and (constructed)
> link tuple. The link basically pointed to an IExternalPage implemented
> page class - so to be precise the whole breadcrumb path consisted of
> bookmarkable pages.
>
> I'm trying to mimic this behavior with T5, using the BeginRender
> annotation on a basepage class method called initPage() and also on the
> basepage class a onActivate() method. I have some questions about it.
> Below the specific base page code:
>
>    protected String getBreadCrumbTitle() {
>        return resources.getMessages().get("title-" +
>           resources.getPageName().toLowerCase());
>    }
>
>    protected Object[] getLinkParameters() {
>        return null;
>    }
>
>    @BeginRender
>    public void initPage() {
>        String pageName = resources.getPageName();
>        Link link = resources.createPageLink(resources.getPageName(),
>              true, getLinkParameters());
>        breadCrumbHolder.checkBreadCrumbForAdd(pageName,
>              getBreadCrumbTitle(), link.toRedirectURI());
>    }
>
>    public void onActivate() {
>        String pageName = resources.getPageName();
>        breadCrumbHolder.checkBreadCrumbForRemove(pageName);
>    }
>
> Q1: the initPage() method is there to create a 'bookmarkable' link -
> amongst others - and store that information in the breadcrumb model. The
> getLinkParameters() is there for a subclass to provide its specific
> activation parameters to be used. Should I use another way to create
> bookmarable links?
>
> Q2: the onActivate() method is there to remove one (or more) crumbs from
> the crumbpath. Since other pages will also need activation - potentially
> with additional arguments - is this onActivate() the best way/place to
> manipulate the model? I'm getting the idea that onActivate() is not the
> designated alternative for T4's activateExternalPage(Object[] parameters,
> IRequestCycle cycle) in IExternalPage interface.
>
> Currently all of this works - although haven't tested activation with
> activation context parameters yet.
>
> Thx.
> -J.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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