Hi,

I frequently have multiple onActivate methods as well. Tapestry will look at the context and see how many parameters there are - let's say there are n parameters. It will then call the method with n parameters - or if none can be found, the one with n-1 parameters, then n-2 parameters and so on.

Now, if you return true from one onActivate method, Tapestry won't call the others. An example:

  Object onActivate() {
    // this will only be called if the page is requested
    //  with no context, so that's probably an error
    // send the user back to the product index
    return ProductIndex.class;
  }

  Object onActivate(Long categoryId) {
    // set up for adding a new product
    return true;
  }

  Object onActivate(Long categoryId, Long productId) {
    // set up for editing a product
    return true;
  }

That's all there is to it.

-Filip

On 2008-06-07 09:59, maxthesecond wrote:


Renat Zubairov wrote:
Why would you need to have multiple parameters in onActivate? Are you
considering using Encoder?
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/PrimaryKeyEncoder.html



Well, it is simply an Update/Create page of a detail element belonging to a
category, so I need to pass the category ID and the product ID wich if it's
0 implies a new product and if not an edition.
The fact is that as pages grow in complexity they tend to have also a more
complex initialization,I have had problems when implementing multiple
onActivate, I'm happy with my solution.
Thanks




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to