Joel Halbert wrote:
> Hi,
>
> Is it possible to have "named" page context parameters? (along the
> lines of Wicket PageParameters).
>
> I would like to be able to have bookmarkable URLs but rather than
> indexing page context parameters (in onActivate) by ordinal in a list
> I would rather key them by name.

You can use Link#addParameter to add named parameters to Link and
Request#getParameter to get parameter value. This is simple way, but
requires some extra coding.


I’ve wrote my simple extension to Tapestry that allows to work with
named parameters the same way as with regular context parameters. You
can either implement your event handlers
(onStoreParameters/onRestoreParameters, their meaning is similar to
onPassivate/onActivate) or use @QueryParameter annotatiton.

Code: http://wfrag.org/files/tapext.zip

You can use it the following way (snippet from page class):

@QueryParameter
private Integer page;

The @QueryParameter works the similar way to @PageActivationContext
annotation

Since createPageLink/createEventLink and t:pagelink/t:eventlink does not
support overriding named parameters, to generate a link with “page”
value other than current one, you can use the following workaround:

// We temporarily set page to current one, to generate proper link,
// since we don't have a way to override parameter values
int saved = page;
page = newpage;
Link link = resources.createPageLink(resources.getPageName(), false);
page = saved;


Also, the code does not work well for primitive types (like “int”), so
it’s better to use wrappers.


-- 
WBR,
Ivan S. Dubrov



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

Reply via email to