I like it also but I believe this is already (for the most part) the
case by default if you leave off the context. Try

public class About
{
        @InjectPage
        private Contact contactPage;
        
        @InjectPage
        private About aboutPage;
        
        private String value;
        
        void init(String value) {
                this.value = value;
        }
        
        void onActivate() {
                contactPage.init("stuff");
                aboutPage.init("other");
        }
        
        public String onPassivate() {
                return value;
        }

}

About.tml
    <t:pagelink page="contact" >contact</t:pagelink>
    <t:pagelink page="about" >about</t:pagelink>

If you wanted multiple links to the same page with different context
you could always use

<t:pagelink page="about" context="aboutPage.onPassivate()">about</t:pagelink>
<t:pagelink page="about" context="aboutPage1.onPassivate()">about 1</t:pagelink>

But that's a bit ugly so it might be handy if the page parameter was
on Object instead of a String then you could just say

<t:pagelink page="aboutPage1">page 1<t:pagelink>
<t:pagelink page="aboutPage2">page 2<t:pagelink>

That way if you call it with a String it would work as before but if
it's a page object it would call onPassivate for each page. Then you
could just say

@Property
@InjectPage
private PageWithLongPath longPage;

<t:pagelink page="longPage">page</t:pagelink>
instead of
<t:pagelink page="page/with/long/classpath/Page">page<t:pagelink>

and you could refactor your page classes without breaking things. The
problem with that is page is a literal so that would not be backward
compatible.

What I'd really like to see is a combination of all this with
eventlink into a link component that takes a page/event/context/zone
and does the right thing. That way I could call any event on any page
with

<t:link page="longPage" event="myEvent">page</t:link>

if you don't specify an event it would work like a pagelink. If you
don't specify a page the default would be the page you are on.

One last thing. If you specify a zone parameter then all Ajax requests
would go to the event. If there is no javascript the request would go
to the page. Then the event does not need to check isXHR() so

<t:link page="longPage" event="zoneEvent" zone="myZone">page</t:link>

calls onZoneEvent to update zones if no javascript it just loads longPage.



Possible points for discussion:



For the above example should you specify the zone event instead of
overloading event

<t:link page="longPage" zoneEvent=zoneEvent" zone="myZone">page</t:link>

Perhaps the default for zoneEvent could be the zone id so

<t:link page="longPage" zone="myZone">page</t:link>

would call onMyZone for zone updates or just load longPage if there is
no javascript.



Should something like

<t:link page="thisPage" event="otherPage.myEvent" zone="myZone">page</t:link>

allow you to load thisPage or call onMyEvent on otherPage. What if you
want different context for the event and page

<t:link page="thisPage" event="thatPage.myEvent(eventContext)"
context="pageContext">page</t:page>

or

<t:link page="thisPage" event="thatPage.myEvent" context="pageContext"
eventContext="eventContext">page</t:page>

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

Reply via email to