You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Thiago H de Paula Figueiredo <th...@gmail.com> on 2015/01/05 12:27:54 UTC
Re: URL Rewrite with Form Validations
On Mon, 29 Dec 2014 12:47:07 -0200, George Christman
<gc...@cardaddy.com> wrote:
> Hi Thiago, The following approach does indeed work, but I'd like to
> verify it to be the correct approach for handling
> ComponentEventLinkTransformer.
Looks good to me. :)
> SimpleLink is basically the class you
> wrote, I'm just not sure if I should be using simplelink with
> transformComponentEventLink.
I'm not sure why
> Also, is there a more efficient way of doing this?
What do you mean by efficient?
> One last thing, I see a Mapper service is being used in the nabble
> example below. What does that service do?
The example below doesn't have any signs of Mapper.
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: URL Rewrite with Form Validations
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 05 Jan 2015 12:59:16 -0200, George Christman
<gc...@cardaddy.com> wrote:
>> I'm not sure why
>
> I ended up finding an alternative to your simplelink approach that I
> seem to like much better. I'd be curious as to your thoughts.
>
> private Link buildLink(String basePath, PageRenderRequestParameters
> parameters, String target, String replacement, String concat) {
> Link link =
> componentEventLinkEncoder.createPageRenderLink(parameters);
> return link.copyWithBasePath(basePath.replace(target, replacement));
> }
Hmmm, that code I wrote was written a long time ago, probably before Link
had the copyWithBasePath() method.
> This was the example found of mapper at the bottom of this nabble
> link. I'm not sure what mapper is used for.
In that example, Mapper isn't a service. Instead, it's the class used as
the distributed configuration of the PageRenderLinkTransformer
implementation, which is also defined as a service. This way, you don't
need to write code for simple x -> y URL rewrites.
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: URL Rewrite with Form Validations
Posted by George Christman <gc...@cardaddy.com>.
I was a little confused, but I was able to resolve everything without issue.
On Mon, Jan 5, 2015 at 6:27 AM, Thiago H de Paula Figueiredo
<th...@gmail.com> wrote:
> On Mon, 29 Dec 2014 12:47:07 -0200, George Christman
> <gc...@cardaddy.com> wrote:
>
>> Hi Thiago, The following approach does indeed work, but I'd like to
>> verify it to be the correct approach for handling
>> ComponentEventLinkTransformer.
>
>
> Looks good to me. :)
>
>> SimpleLink is basically the class you
>> wrote, I'm just not sure if I should be using simplelink with
>> transformComponentEventLink.
>
>
> I'm not sure why
I ended up finding an alternative to your simplelink approach that I
seem to like much better. I'd be curious as to your thoughts.
private Link buildLink(String basePath, PageRenderRequestParameters
parameters, String target, String replacement, String concat) {
Link link = componentEventLinkEncoder.createPageRenderLink(parameters);
return link.copyWithBasePath(basePath.replace(target, replacement));
}
>
>> Also, is there a more efficient way of doing this?
>
>
> What do you mean by efficient?
>
>> One last thing, I see a Mapper service is being used in the nabble
>> example below. What does that service do?
>
>
> The example below doesn't have any signs of Mapper.
This was the example found of mapper at the bottom of this nabble
link. I'm not sure what mapper is used for.
PageRenderLinkTransformer {
private List<Mapper> _mappers;
private ComponentEventLinkEncoder _encoder;
public StringMapperPageRenderLinkTransformer(List<Mapper> mappers,
ComponentEventLinkEncoder encoder) {
_mappers = mappers;
_encoder = encoder;
}
public Link transformPageRenderLink(Link defaultLink,
PageRenderRequestParameters parameters) {
for (Mapper mapper : _mappers) {
if (defaultLink.getBasePath().contains(mapper.getFrom())) {
return
defaultLink.copyWithBasePath(defaultLink.getBasePath().replace(mapper.getFrom(),
mapper.getTo()));
}
}
return null;
}
public PageRenderRequestParameters decodePageRenderRequest(Request
request) {
for (Mapper mapper : _mappers) {
if (request.getPath().contains(mapper.getTo())) {
final String mapped =
request.getPath().replace(mapper.getTo(), mapper.getFrom());
return _encoder.decodePageRenderRequest(
new DelegatingRequest(request) {
@Override
public String getPath() {
return mapped;
}
});
}
}
return null;
}
>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
Thanks Thiago, happy new years.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org