Hi,

I think I found a simple way of passing named context parameters between pages and this is to create a custom ValueEncoder for map objects. I created a MapValueEncoder, and my intention was for it to do the following :

Encode a Map of String/Object pairs to a string of the following form: key1/value1/key2/value2 etc... (and of course decode said string back to a map that can be passed to the context)

This has the advantage (I thought) of creating nice URLs from my map context e.g.

www.mysite.com/key1/value1/key2/value2

The problem is that the context string is URL encoded so that the forward slashes come out as key1%252F%252Fvalue1%252F%252Fkey2%252F%252Fvalue2

Is there anyway to override the default encoding of TapestryInternalUtils.encodeContext(id) ?

thx

Joel Halbert wrote:
Hi Ivan,

I'm trying out your extension, thanks, one question though:
The following class seems to be missing from the zip you linked to below (http://wfrag.org/files/tapext.zip):

ru.nsc.ict.catalogue.annotations.QueryParameter

can i get it anywhere?

Thx
Joel

Ivan Dubrov wrote:
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.




--
SU3 Analytics Ltd
61b Oxford Gardens
W10 5UJ
London

Tel: +44 20 8960 2634
Mob: +44 75 2501 0825
www.su3analytics.com

SU3 Analytics Ltd is a company registered in England and Wales under company 
number 06639473 at registered address 61b Oxford Gardens, London W10 5UJ, 
United Kingdom.



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

Reply via email to