This method has to be rewritten:

public final void mountPackage(String path, Package packageToMount)
    {
        if (!path.startsWith("/"))
        {
            path = "/" + path;
        }

        mountPath(path, new PackagePathMountEncoder(path, packageToMount));
    }

to not use the Package object (so that users don't have to do MyClass.class.getPackage())

Because getPackage() doesn't have to return the package it can also return null (and we know that because we already had these problems in wicket!!)

So my fix would be to also give the class object in that method:

public final void mountPackage(String path, Class classForThePackage)
    {
        if (!path.startsWith("/"))
        {
            path = "/" + path;
        }

        mountPath(path, new PackagePathMountEncoder(path, classForThePackage));
    }


and then we can look inside our code if the Package object is there or else extract it as a string from the classname.

johan

On 12/11/05, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
Hi,

I just comitted a new batch of refactorings concerning mounting and
request targets in general. I seperated the request targets into more
packages, got rid of 'extends' in interfaces where they needen't be,
and got rid of the tagging interface for session synchronization (is
now a boolean method in IRequestTarget).

The mounting can now be done much more flexible. Besides the page
mounting we already had, I provided an implementation of package
mounting (and an example for it) so that you can mount a whole package
in one call. For example:

In NiceUrlApplication:

  Package package1 = Page3.class.getPackage();
  mountPackage("/my/mounted/package", package1);

Generates urls like:

http://localhost:8080/wicket-examples/niceurl/my/mounted/package/Page5/param2/-61135299/param1/884870759

my/mounted/package -> the mounted path
wicket.examples.niceurl.mounted -> mounted package
Page5 -> Page5.class
and then the parameters


People, please go ahead and play with it so that we can get the test
hours we need :)

One thing to consider is that this (currently?) only works for
bookmarkable pages. Maybe that is good, maybe it is not. For example,
say you have callbacks (like forms and links) on your mounted page,
they will resolve to the default encoding again. E.g:

http://localhost:8080/wicket-examples/niceurl/my/mounted/package/Page4

with a Link on it will point to e.g.:

http://localhost:8080/wicket-examples/niceurl?path=1

while you might say that instead you would expect this to stay in the
mounted path like:

http://localhost:8080/wicket-examples/niceurl/my/mounted/package/?path=1

or something similar. I'm about to go offline for two days I expect,
but why don't you guys have a nice discussion on this, and if the
concensus would be that the latter would be more appropriate, please
someone implement it! :)

Eelco


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&opclick
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to