because then everything that comes in matches!
So the PackageRequestTargetUrlCodingStrategy always matches
for example if i change the niceurlapp to mound the package example on /
then http://localhost:8080/wicket/niceurl//Page5
ofcourse works fine
but if i do:
http://localhost:8080/wicket/niceurl//Page5.jpg
then:
ERROR - RequestCycle - Unable to load class with name: wicket.examples.niceurl.mounted.Page5.jpg
wicket.WicketRuntimeException: Unable to load class with name: wicket.examples.niceurl.mounted.Page5.jpg
at wicket.application.DefaultClassResolver.resolveClass(DefaultClassResolver.java:66)
at wicket.request.target.coding.PackageRequestTargetUrlCodingStrategy.decode(PackageRequestTargetUrlCodingStrategy.java:80)
So this means that everything that comes through always matches to the PackageRequestTarget..
because of this code:
public final IRequestTargetUrlCodingStrategy urlCodingStrategyForPath(final String path)
{
if (path == null)
{
return (IRequestTargetUrlCodingStrategy)mountsOnPath.get(null);
}
else if (!path.equals("/")) // ignore root paths.. is this the right
// path?
{
for (final Iterator it = mountsOnPath.entrySet().iterator(); it.hasNext();)
{
final Map.Entry entry = (Entry)it.next();
final String key = (String)entry.getKey();
if (path.startsWith(key))
{
return (IRequestTargetUrlCodingStrategy)entry.getValue();
}
}
}
return null;
because mountsOnPath does contains / as last. And all arguments that comes in starts with a /
so everything matches.
So to really fix it we need another match() method in the IRequestTargetUrlCodingStrategy
match(RequestParameters) and almost everything can directly return true i guess
except the package mounter that one has to check if the class can be loaded..
But this would mean that there will be some method changes.. and maybe some api breaks i guess.
johan
On 5/8/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
Yeah, I'm feeling really lazy today, so anything that works well for
both Johan and Bruno is fine by me. ;)
Eelco
On 5/8/06, Igor Vaynberg <[EMAIL PROTECTED] > wrote:
> i guess we ended up using the coding strategies only for mounting at the
> end, so yeah thats fine by me.
>
> since its your idea you should build it :)
>
> -Igor
>
>
>
> On 5/8/06, Johan Compagner <[EMAIL PROTECTED]> wrote:
> >
> > but then every IRequestTargetUrlCodingStrategy must do
> the same check?
> >
> > What i would like to have in that interface is : getPath()
> >
> > and the remove that stupid String path argument from the:
> >
> > mount(String path, IRequestTargetUrlCodingStrategy encoder)
> >
> >
> > Every IRequestTargetUrlCodingStrategy already does have
> the path where its bound on
> > Because else the decode/encode will never work.
> >
> > and is it really the responsiblity of an IRequestTargetUrlCodingStrategy
> class to check a path?
> > It is more for the IRequestTargetMounter that class should be in control
> over the paths.
> > Only PackageXX is a special case bsecause the path you mound on is not
> really the "complete" path..
> >
> >
> > johan
> >
> >
> >
> >
> >
> >
> > On 5/8/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
> > >
> > > thats pretty much what i was thinking. i was also considering adding the
> checkMountPath to IRequestTargetUrlCodingStrategy so that it is a bit more
> explicit.
> > >
> > > what do other devels think?
> > >
> > >
> > > -Igor
> > >
> > >
> > >
> > > On 5/8/06, Bruno Borges < [EMAIL PROTECTED] > wrote:
> > > >
> > > > So, I did the changes.
> > > >
> > > > IRequestTargetUrlCodingStrategy
> > > >
> > > > void checkMountPath(String path);
> > > >
> > > > AbstractRequestTargetUrlCodingStrategy
> > > >
> > > > public void checkMountPath(String path)
> > > > {
> > > > if (path == null)
> > > > {
> > > > throw new
> IllegalArgumentException("Argument path must be not-null");
> > > >
> > > > }
> > > > if (path.equals("/"))
> > > > {
> > > > throw new IllegalArgumentException(
> > > > "The mount path '/' is reserved for the
> application home page");
> > > > }
> > > > }
> > > >
> > > >
> > > > PackageRequestTargetUrlCodingStrategy
> > > >
> > > > public void checkMountPath(String path)
> > > > {
> > > > if (path == null)
> > > > {
> > > > throw new
> IllegalArgumentException("Argument path must be not-null");
> > > > }
> > > >
> > > > // NOT NEEDED FOR PACKAGE TARGET
> > > > /*
> > > >
> > > > if (path.equals("/"))
> > > > {
> > > > throw new IllegalArgumentException(
> > > > "The mount path '/' is reserved for the
> application home page");
> > > > }
> > > >
> > > > */
> > > > }
> > > >
> > > > WebRequestCodingStrategy
> > > >
> > > >
> > > > public final void mount(String path,
> IRequestTargetUrlCodingStrategy encoder)
> > > > {
> > > >
> > > > if (encoder == null)
> > > > {
> > > > throw new
> IllegalArgumentException("Argument encoder must be
> not-null");
> > > > }
> > > >
> > > > encoder.checkMountPath(path);
> > > >
> > > > .....
> > > > }
> > > >
> > > > It worked just fine.
> > > >
> > > > And I've looked into the code, and I couldn't find any other place
> that should call checkMountPath from the codingStrategy.
> > > >
> > > >
> > > > Regards,
> > > >
> > > >
> > > > On 5/8/06, Igor Vaynberg < [EMAIL PROTECTED] > wrote:
> > > > >
> > > > > yeah, this wasnt going to be a quicky like i thought.
> > > > >
> > > > > one way to do this is to let the coding strategy be responsible for
> checking the mount path. we can have a default method in the abstract to
> help.
> > > > >
> > > > > the problem is that creators of strategies must now know that they
> need to do the check. usually its us core devels so we know, but ...
> > > > >
> > > > > maybe others can weigh in and discuss some options.
> > > > >
> > > > >
> > > > > -Igor
> > > > >
> > > > >
> > > > > On 5/8/06, Bruno Borges <[EMAIL PROTECTED] > wrote:
> > > > > >
> > > > > > Where are you going to remove an "if check" ? Because I think that
> might be a problem if you remove the complete
> > > > > >
> > > > > > public final void mount(String path,
> IRequestTargetUrlCodingStrategy encoder) {
> > > > > > ...
> > > > > > if (path.equals ("/"))
> > > > > > {
> > > > > > throw new IllegalArgumentException(
> > > > > > "The mount path '/' is reserved for the
> application home page");
> > > > > > }
> > > > > > ...
> > > > > > }
> > > > > >
> > > > > > from the WebRequestCodingStrategy.
> > > > > >
> > > > > > the patch is to check if the relying
> IRequestTargetUrlCodingStrategy encoder is of type
> PackageRequestTargetUrlCodingStrategy. If so, leave it do
> the mount.
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > On 5/8/06, Igor Vaynberg < [EMAIL PROTECTED] > wrote:
> > > > > > >
> > > > > > > ok, just wanted to make sure the functionality for routing
> packages mounted on / was still working. i think jonathan added that if
> check because he was unaware of this usecase. i will clean it up.
> > > > > > >
> > > > > > >
> > > > > > > -Igor
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On 5/8/06, Bruno Borges <[EMAIL PROTECTED] > wrote:
> > > > > > > >
> > > > > > > > Movin to the correct list...
> > > > > > > >
> > > > > > > > I did a change in the line
> > > > > > > >
> > > > > > > >
> wicket.protocol.http.request.WebRequestCodingStrategy:258
> > > > > > > >
> > > > > > > > if ( path.equals("/") && encoder instanceof
> PackageRequestTargetUrlCodingStrategy == false)
> > > > > > > >
> > > > > > > > Looks like everything went fine.
> > > > > > > >
> > > > > > > > But this was a first shot on how to fix the problem. Maybe
> theres a better solution.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On 5/8/06, Igor Vaynberg <[EMAIL PROTECTED] > wrote:
> > > > > > > > >
> > > > > > > > > can you remove that if statement and see if it works?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Igor
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 5/8/06, Bruno Borges < [EMAIL PROTECTED] > wrote:
> > > > > > > > > >
> > > > > > > > > > And is exactly that. it throws an exception saying that
> the path can't be "/". I saw the source and there's an If statement checking
> for this.
> > > > > > > > > >
> > > > > > > > > > :)
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 5/8/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
> > > > > > > > > > >
> > > > > > > > > > > if you are talking about mounting a package on / then
> you should be able to do that with something like mount("/",
> PackageName.for(Index.class));
> > > > > > > > > > >
> > > > > > > > > > > then if you have an Index.class page in that package it
> should be accessible from /site/Index
> > > > > > > > > > >
> > > > > > > > > > > at least i remember i wrote this functionality in
> because it was requested before. maybe it got lost with some of the
> refactorings we did. if so, then we should fix it.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Igor
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On 5/8/06, Bruno Borges <[EMAIL PROTECTED]> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Yeah, it's /site/*, I just cutted off the unnecessary
> info. Sorry... :D
> > > > > > > > > > > > So, how about something like:
> > > > > > > > > > > >
> > > > > > > > > > > > mountByClassName(String underPath, PackageName pkg);
> > > > > > > > > > > >
> > > > > > > > > > > > this would be the same as loop through all classes
> located under the pkg and create a mounted path with the same name as the
> class.
> > > > > > > > > > > >
> > > > > > > > > > > > I know this can be done outside Wicket's core API.
> Just calling some of the already built-in methods. But it would be nice to
> have a shortcut.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > On 5/8/06, Igor Vaynberg < [EMAIL PROTECTED] >
> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > you cannot mount onto / because that is reserved for
> the homepage, so in a way homepage is always mounted on /
> > > > > > > > > > > > >
> > > > > > > > > > > > > if you want to mount something onto /site/index then
> you need to mount on /index not /
> > > > > > > > > > > > > mount("/index", Index.class);
> > > > > > > > > > > > >
> > > > > > > > > > > > > btw, your url mapping should be /site/* not just
> /site
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > -Igor
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > On 5/8/06, Bruno Borges < [EMAIL PROTECTED]>
> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Why can't I mount my pages so they all can be
> bookmarkable from "/" ?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Just a note: the WicketServlet is under
> url-pattern = /site, so my pages would be bookmarkable like "/site/Index".
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --
> > > > > > > > > > > > > > Bruno Borges
> > > > > > > > > > > > > > [EMAIL PROTECTED]
> > > > > > > > > > > > > > Sun Certified Java Programmer for 1.4
> > > > > > > > > > > > > > Sun Certified Web Component Developer for 1.4
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > Bruno Borges
> > > > > > > > > > > > [EMAIL PROTECTED]
> > > > > > > > > > > > Sun Certified Java Programmer for 1.4
> > > > > > > > > > > > Sun Certified Web Component Developer for 1.4
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Bruno Borges
> > > > > > > > > > [EMAIL PROTECTED]
> > > > > > > > > > Sun Certified Java Programmer for 1.4
> > > > > > > > > > Sun Certified Web Component Developer for 1.4
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Bruno Borges
> > > > > > > > [EMAIL PROTECTED]
> > > > > > > > Sun Certified Java Programmer for 1.4
> > > > > > > > Sun Certified Web Component Developer for 1.4
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Bruno Borges
> > > > > > [EMAIL PROTECTED]
> > > > > > Sun Certified Java Programmer for 1.4
> > > > > > Sun Certified Web Component Developer for 1.4
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Bruno Borges
> > > > [EMAIL PROTECTED]
> > > > Sun Certified Java Programmer for 1.4
> > > > Sun Certified Web Component Developer for 1.4
> > >
> > >
> >
> >
>
>
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmdlnk&kid0709&bid&3057&dat1642
_______________________________________________
Wicket-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop