Re: unmount sub url

2008-05-09 Thread Sebastiaan van Erk

I made a JIRA for this (with patch).

https://issues.apache.org/jira/browse/WICKET-1603

Regards,
Sebastiaan

Sebastiaan van Erk wrote:

Eelco Hillenius wrote:
On Thu, May 8, 2008 at 3:15 PM, Sebastiaan van Erk 
[EMAIL PROTECTED] wrote:

2) using a special RequestCodingStrategy, i.e.
UnmountedRequestCodingStrategy and tweaking isWicketRequest to return 
false

if it detects this request coding strategy...

What do you guys think?


Well, my first impulse is to say that mounting was never meant to
serve complex cases, and that instead of mounting you'd do best with a
custom request coding strategy instead.

That said though, I'm not against something like 2 if we have a nice
construct for it.

Eelco


I made a proof of concept which works, though I have some questions 
about it (I'm not really into the whole request coding strategy API). 
Basically what I did was:


1) Add PassThroughUrlCodingStrategy:

public class PassThroughUrlCodingStrategy extends 
AbstractRequestTargetUrlCodingStrategy

{
public PassThroughUrlCodingStrategy(final String mountPath) {
super(mountPath);
}

public IRequestTarget decode(RequestParameters requestParameters) {
return null;
}

public CharSequence encode(IRequestTarget requestTarget) {
return null;
}

public boolean matches(IRequestTarget requestTarget) {
return false;
}
}

That's the one I have questions about: I'm not quite sure how to 
implement these methods properly.


2) Modify wicket filter isWicketRequest

// Mounted page
IRequestTargetUrlCodingStrategy urlCodingStrategy = 
webApplication.getRequestCycleProcessor()

.getRequestCodingStrategy()
.urlCodingStrategyForPath(relativePath);

// Mounted and not pass through?
return urlCodingStrategy != null 
!(urlCodingStrategy instanceof PassThroughUrlCodingStrategy);

3) Mount my PassThroughUrlCodingStrategy in my Application.init() method:

mount(new QueryStringUrlCodingStrategy(/path1, MyPage.class));
mount(new PassThroughUrlCodingStrategy(/path1/dir));

4) Fired up tomcat and tested it. :-) It works...

That leaves me with the questions about the decode, encode and 
matches... How should I implement them properly? :-)


Regards,
Sebastiaan



smime.p7s
Description: S/MIME Cryptographic Signature


unmount sub url

2008-05-08 Thread Sebastiaan van Erk

Hi,

I've got a page mounted on /path1.

I've got some files in a directory in my webapp root on /path1/dir

How can I tell Wicket to give control back to the servlet container for 
dir? Currently (even using QueryStringUrlCodingStrategy) the mount eats 
/path1/dir and doesn't let me access the files there...


Regards,
Sebastiaan


smime.p7s
Description: S/MIME Cryptographic Signature


Re: unmount sub url

2008-05-08 Thread Sebastiaan van Erk

 Hi,

 I've got a page mounted on /path1.

 I've got some files in a directory in my webapp root on /path1/dir

 How can I tell Wicket to give control back to the servlet container for
 dir? Currently (even using QueryStringUrlCodingStrategy) the mount eats
 /path1/dir and doesn't let me access the files there...

 Regards,
 Sebastiaan

I looked at the wicket filter code, and it does not seem that this is 
possible at the moment (though I might be missing something). I see at 
least two possible ways to add this feature:


1) using a special exception (I did not think about the name):

if (isWicketRequest(relativePath))
{
try
{
...
}
catch (NotWicketAfterAllException e) {
// Pass down the filter chain.
chain.doFilter(request, response);
}
finally
{
// always unset the application thread local
Application.unset();
RequestContext.unset();
}
}

2) using a special RequestCodingStrategy, i.e. 
UnmountedRequestCodingStrategy and tweaking isWicketRequest to return 
false if it detects this request coding strategy...


The first solution is more powerful (it allows you to pass the request 
down the filter chain from pretty much anywhere), but it might be a bit 
dangerous (what if you already read from the request/response, etc), and 
it requires your own request strategy implementation to check if it 
happens to be an url that you want to pass down the filter chain which 
usually ends up being ugly string compares)...


The second solution is cleaner in my opinion and it would allow you to 
unmount or mount as a pass through specific urls...


What do you guys think?

Regards,
Sebastiaan

Sebastiaan van Erk wrote:



smime.p7s
Description: S/MIME Cryptographic Signature


Re: unmount sub url

2008-05-08 Thread Eelco Hillenius
On Thu, May 8, 2008 at 3:15 PM, Sebastiaan van Erk [EMAIL PROTECTED] wrote:
 Hi,

 I've got a page mounted on /path1.

 I've got some files in a directory in my webapp root on /path1/dir

 How can I tell Wicket to give control back to the servlet container for
 dir? Currently (even using QueryStringUrlCodingStrategy) the mount eats
 /path1/dir and doesn't let me access the files there...

 Regards,
 Sebastiaan

 I looked at the wicket filter code, and it does not seem that this is
 possible at the moment (though I might be missing something). I see at least
 two possible ways to add this feature:

 1) using a special exception (I did not think about the name):
 ...
 2) using a special RequestCodingStrategy, i.e.
 UnmountedRequestCodingStrategy and tweaking isWicketRequest to return false
 if it detects this request coding strategy...

 What do you guys think?

Well, my first impulse is to say that mounting was never meant to
serve complex cases, and that instead of mounting you'd do best with a
custom request coding strategy instead.

That said though, I'm not against something like 2 if we have a nice
construct for it.

Eelco

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



Re: unmount sub url

2008-05-08 Thread Sebastiaan van Erk

Eelco Hillenius wrote:

On Thu, May 8, 2008 at 3:15 PM, Sebastiaan van Erk [EMAIL PROTECTED] wrote:

2) using a special RequestCodingStrategy, i.e.
UnmountedRequestCodingStrategy and tweaking isWicketRequest to return false
if it detects this request coding strategy...

What do you guys think?


Well, my first impulse is to say that mounting was never meant to
serve complex cases, and that instead of mounting you'd do best with a
custom request coding strategy instead.

That said though, I'm not against something like 2 if we have a nice
construct for it.

Eelco


I made a proof of concept which works, though I have some questions 
about it (I'm not really into the whole request coding strategy API). 
Basically what I did was:


1) Add PassThroughUrlCodingStrategy:

public class PassThroughUrlCodingStrategy extends 
AbstractRequestTargetUrlCodingStrategy

{
public PassThroughUrlCodingStrategy(final String mountPath) {
super(mountPath);
}

public IRequestTarget decode(RequestParameters requestParameters) {
return null;
}

public CharSequence encode(IRequestTarget requestTarget) {
return null;
}

public boolean matches(IRequestTarget requestTarget) {
return false;
}
}

That's the one I have questions about: I'm not quite sure how to 
implement these methods properly.


2) Modify wicket filter isWicketRequest

// Mounted page
IRequestTargetUrlCodingStrategy urlCodingStrategy = 
webApplication.getRequestCycleProcessor()

.getRequestCodingStrategy()
.urlCodingStrategyForPath(relativePath);

// Mounted and not pass through?
return urlCodingStrategy != null 
!(urlCodingStrategy instanceof PassThroughUrlCodingStrategy);

3) Mount my PassThroughUrlCodingStrategy in my Application.init() method:

mount(new QueryStringUrlCodingStrategy(/path1, MyPage.class));
mount(new PassThroughUrlCodingStrategy(/path1/dir));

4) Fired up tomcat and tested it. :-) It works...

That leaves me with the questions about the decode, encode and 
matches... How should I implement them properly? :-)


Regards,
Sebastiaan



smime.p7s
Description: S/MIME Cryptographic Signature