Extract ID from Tapestry URLs
I have a tapestry url that looks like
http://localhost:88开发者_如何学JAVA88/forwardtask/88
how do i get the 88 bit? thanks. Tapestry is such a pain to use
Have a look at the page navigation section in the Tapestry 5 docs, particularly Page Activation.
Effectively, you'll want this in your page class:
void onActivate(long forwardTaskId) {
...
}
This bit will execute before the page renders if there is a parameter in the URL.
Tapestry has some non-obvious concepts that you'll have to understand to be effective, but it's not rocket science. Good luck!
If you are using a newer version 5.1 Tapestry you can just create a variable like:
@PageActivationContext
int myNumber
typically (althought I dont know all the cases) paths in Tapestry are defined by OnActivate and onPassivate and they are generated by event context clicks (pagelink,actionlink,eventlink). check the context elements in the .tml your coming from and then look at the Active and Passive methods on the page your going to.
精彩评论