Hi George

I have a similar scenario, but the main difference is that I don't
know before hand the names of the query parameters.
I only have one page with this particular requirement so I do all the
URL query parameters encoding directly in the same page using the
events: DECORATE_PAGE_RENDER_LINK and DECORATE_COMPONENT_EVENT_LINK

Here is how my code looks like:

@OnEvent(EventConstants.ACTIVATE)
void activate(EventContext context)
{
        filters = new ArrayList<Filter>();
        decodeFiltersFromRequest(request);
}

@OnEvent(EventConstants.DECORATE_PAGE_RENDER_LINK)
void decoratePageRenderLink(Link link, PageRenderRequestParameters parameters)
{
        encodeFiltersIntoLink(link);
}

@OnEvent(EventConstants.DECORATE_COMPONENT_EVENT_LINK)
void decorateComponentEventLink(Link link,
ComponentEventRequestParameters parameters)
{
        encodeFiltersIntoLink(link);
}

private void encodeFiltersIntoLink(Link link)
{
        if (filters != null) {
                for (Filter filter : filters)
                {
                        link.addParameter(filter.getAttribute().getId(),
urlEncoder.encode(filter.getValue()));
                }
        }
}

private void decodeFiltersFromRequest(Request request)
{
        for (String parameter : request.getParameterNames())
        {
                // do not care about tapestry internal form parameters
                // && do not care about page form parameters
                // && DO NOT care about chenillekit's AbstractEventMixin 
"value" parameter
                if (!parameter.startsWith("t:") && !parameter.startsWith("f_") 
&&
!"value".equals(parameter))
                {
                        FilterAttribute attribute = 
session.get(FilterAttribute.class, parameter);
                        if (attribute != null)
                        {
                                String[] params = 
request.getParameters(parameter);
                                for (String param : params)
                                {
                                        filters.add(new Filter(attribute, 
urlEncoder.decode(param)));
                                }
                        } else {
                                // do something else
                                logger.error("weird request parameters names: " 
+
request.getParameterNames().toString());
                        }
                }
        }
}


I hope it helps.

Cheers.
Alejandro.

On Wed, Oct 17, 2012 at 4:11 PM, George Christman
<gchrist...@cardaddy.com> wrote:
> As always, thanks Lance / Thiago, I think at this point you guys have
> answered all my base questions. As far as my logic question, I think that it
> is probably best suited for stack overflow as it doesn't completely relate
> to tapestry. Hopefully this post will help others in the future who may be
> trying to build some sort of eCommerce site.
>
>
>
> --
> View this message in context: 
> http://tapestry.1045711.n5.nabble.com/How-to-remove-query-parmeter-from-url-string-tp5716922p5717007.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to