1) If you're using action links, then
onXML won't work. The proper "magic method" naming is:
on<eventname>[from<componentname>]
as:
onActionFromXml, and so forth.
If you want:
onXML() {} then you need to use an event link with the event name of
xml.
I'm not /quite/ sure what you mean by "doesn't pass the parameters as
expected".
There are two different "contexts" at play when you're using an event
link or an action link: the link context, and the page's activation
context. In an action link, at least, the page's activation context
winds up in a query parameter like: t:ac=<contextvalues>. Then the
context from the action or event link is also used, and /these/ values
are what are passed to the event handler method. So as long as your
"onPassivate" correctly returns the current activation context state,
then your onActivate handler should be called for event and action
links, and then the only issue left is to handle your events however
you want to handle them.
Robert
PS: I don't see EventContext implementing Iterable<String>. It just
doesn't make sense from a semantic POV, even it makes things a bit
more convenient. It's also a "public" interface; it's not going to
change anytime soon. :)
On May 15, 2009, at 5/1510:36 AM , Andy Buckley wrote:
Any replies to this (see below, or my previous mail in this thread)?
Specifically, can I use Tapestry components to link "bookmarkably"
to page events as a way of displaying the page in alternative
formats (inc. different MIME types)? And if this is an abuse of the
events system, what alternative approach do you recommend for
(extensible) alternative page formats?
Cheers,
Andy
Andy Buckley wrote:
This has sparked an extra question, though: I also want to be able to
render my data records in several different ways, i.e. nice HTML
tables
by default, but also structured plain text, XML, plotting code and
other
formats on demand. Like the main page, these should be accessible via
the URL. So far, I've been using event handlers, e.g.
.../view:xml?irn=1245569&d=1
to call a View.onXML() method. In moving to this new regexy context
encoding, I tried using ActionLinks to make these alternative-format
links, but it doesn't pass the parameters as expected: I have to
add an
"@OnEvent(component="xml")" annotation to the onXML() method for it
to
work at all, and when I do that the ActionLink uses a dot in the URL
rather than a colon, and ignores the context. I assume there's some
session magic going on to make it work at all, but it means that the
alternative formats can't be accessed via URLs. If I explicitly build
the URL with the context used before, e.g.
.../view.xml/irn1245569/d1
then I get an exception. Is there a way that I can keep using event
handlers for alternative formats and still pass the context params in
the URL? I'd rather not have to split all these formats off into
separate pages, since each contains relatively little logic and the
context decoding seems best defined in the page class (not least for
class reloading convenience.) Looking forward to more useful
answers ;)
By the way, T5 developers, it would be nice if the EventContext was
Iterable<String>, so the old-style for-loop can be replaced with
something more Java 5+ish like "for (String s : context) { ..." for
those who just want strings back from the URL context. But that's a
minor, minor point! ;)
Thanks again,
Andy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org