Your onActivate method can also take varargs, as in void onActivate (String... args) { _firstObj = restoreFirstObj(args[0]); if (args[1] != null) _secondObj = restoreSecondObj(args[1]); ... }
String[] onPassivate () { List<String> args = new ArrayList<String>(); args.add (_firstObj.toString()); if (_secondObj != null) args.add (_secondObj.toString()); .... return (String[]) args.toArray(); } On Sun, Mar 23, 2008 at 12:11 AM, Yura Tkachenko < [EMAIL PROTECTED]> wrote: > Hi All, > > I've been reading chapter about "Page Activation Context" here: > http://tapestry.apache.org/tapestry5/tapestry-core/guide/pagenav.html. And > I > have a question: can I pass using activation context more than one > parameter? > > For example in help we have an example: > > void onActivate(long productId) { > setProductId(productId); > loadProduct(); > } > > long onPassivate() { > return getProductId(); > } > > Also it was mentioned onPassivate method should be like a mirror of > onActivate. Does it means I can't pass more than one parameter? > Another approach I tried is it create another Java Bean (wrapper object) > and > simple try to pass this bean via activation context. In that case my > onActivate and onPassivate were: > > void onActivate(PageWrapper wrappedData) { > System.out.println("Activated with message: " + wrappedData); > setWrapper(wrappedData); > } > > PageWrapper onPassivate() { > System.out.println("Page is passivated."); > return getWrapper(); > } > > As the result I got exception. From URL I understood that Typestry during > passing parameter via activation context is converting it to get request. > In > my case for wrapped object URL was: > > http://localhost:8080/t5first/second/com.packtpub.t5first.utils.PageWrapper%40307efc > After looking to that URL I realized that T5 just call toString of passed > object :-) > So my additional questions: > 1) Why not allow to user pass his own objects (POJO)? > 2) Why not pass data via HTTP POST? Because as far as I know HTTP (at > least > some browsers and http servers) has some limitations to the length of > URLs. > Besides sooner or later some smart users will pass string with a few > Kbytes > and the page will get wrong data (truncated). > > Thanks, > Yura. > > Thanks, > Yura. >