[I'm sending again slightly modified because the first response got
spam-blocked - dunno why - hopefully you're not getting this twice]

I did something similar to this a while back and came up with the
following solution.  It may not be the best way, but what I do is
extend WicketFilter and catch the path there, checking it for style,
and then stripping the style part and passing it to Wicket.  The
problem with this solution is that you must then front-end the app
with something like Apache, and do ProxyPass /app http://{your
localhost : your port }/app/yourstyleforthisdomain - and do that for
each domain.  This wasn't a problem for me because I was already using
Apache on the frontend.  But it makes testing at regular old localhost
port 8081 (or whatever port) practically impossible - you have to set
up Apache on your test machines, too.  Again, this was something I
already do anyway, but I want to mention the drawbacks of this.  Also
notice that my ProxyPass passes from one folder depth to two - because
in the filter I'm going to strip one folder depth off - this will
become important with your cookie handling - so that they end up being
set on the same path as you're really displaying the app.

public class SiteDifferentiatingFilter extends WicketFilter {
    private static final Logger LOGGER =
Logger.getLogger(SiteDifferentiatingFilter.class);

    @Override
    public String getRelativePath(HttpServletRequest request) {
        String path = super.getRelativePath(request);
        // Site is an enum of all sites
        for (Site site : Site.values()) {
            if (path.startsWith(site.getKey())) {
                if (RequestCycle.get() != null && Session.get() != null) {
                    Session.get().setStyle(site.getStyleName());
                    // this is a variation of what I did...  I actually created
                    //    my own site-aware session and set the Site on it so
                    //    that I could see what site they were on in
their session
                    //    and I also used this to switch which
application context
                    //    I was using so that I could have different
service settings
                    //    per site.  Here's the code I used if you're
interested:
                    /*
                    ((SiteDifferentiatingWebSession)
Session.get()).setSite(site);
                    ApplicationContextFactory.getFactory().setSite(site);
                    */
                }
                path = path.substring(site.getKey().length());
                if (path.startsWith("/")) {
                    path = path.substring(1);
                }
                return path;
            }
        }
        return path;
    }
}

Hope this helps - it works, but it is probably not the cleanest
solution out there.  I've had it in production on this group of sites
for quite a while and have not had a bug appear because of it.
--
Jeremy Thomerson
http://www.wickettraining.com


On Tue, Dec 2, 2008 at 7:09 AM, Mathias P.W Nilsson
<[EMAIL PROTECTED]> wrote:
>
> Can url rewrite be used for this. I guess there are alot of people that want
> custom made css and so on based on a url
>
> http://localhost/test/hello
> http://localhost/test2/hello
>
> Can this be done with wicket?
>
> --
> View this message in context: 
> http://www.nabble.com/Create-custom-UrlCodingStrategy-tp20660813p20791796.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

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

Reply via email to