We do something similar to what you're describing.

package com.vegas.athena;

import java.net.URL;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;

import wicket.util.file.IResourceFinder;
import wicket.util.resource.IResourceStream;
import wicket.util.resource.UrlResourceStream;
import wicket.util.resource.locator.AbstractResourceStreamLocator;
import wicket.util.string.Strings;

public class WebPageResourceStreamLocator extends AbstractResourceStreamLocator
{
        private String DEFAULT_STYLE = "default";
        private IResourceFinder finder;

        public WebPageResourceStreamLocator(IResourceFinder finder)
        {
                this.finder = finder;
        }

        public IResourceStream locate(final Class clazz, String path, final
String style,
                        final Locale locale, String extension)
        {

                if (extension == null)
                {
                        extension = "." + Strings.lastPathComponent(path, '.');
                        path = Strings.beforeLastPathComponent(path, '.');
                }

                else
                {
                        if (!extension.startsWith("."))
                        {
                                extension = "." + extension;
                        }
                }

                List<URL> urls = new ArrayList<URL>();
                if (locale != null)
                        urls.addAll(getFilePathSearchList(style, path + "_" +
locale.getLanguage() + extension));
                urls.addAll(getFilePathSearchList(style, path + extension));
                for (URL url : urls)
                        if (url != null)
                                return new UrlResourceStream(url);
                return null;
        }

        @Override
        protected IResourceStream locate(Class clazz, String path)
        {
                // TODO Auto-generated method stub
                return null;
        }

        private LinkedList<URL> getFilePathSearchList(String style, String path)
        {
                LinkedList<URL> pathList = new LinkedList<URL>();

                // style/path
                pathList.add(finder.find(style + "/" + path));

                // defaultStyle/path
                pathList.add(finder.find(DEFAULT_STYLE + "/" + path));

                // path
                pathList.add(finder.find(path));

                return pathList;
        }

}

Scott

On 7/26/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> yeah, its possible. try to search for custom markup loading. you can make
> wicket load markup from anywhere you want, just have to install your own
> IResouceStreamLocator into settings.
>
> also search the list, there are a lot of threads on how to do this.
>
> -igor
>
>
> On 7/26/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > Thanks for the quick response, that looks like what I need.  One
> > followup question that isn't clear from that FAQ page (sorry if it is
> > another newbie question).  From a file layout point of view would it
> > possible to do this sort of thing...
> >
> > /sites/client1/Page1.html
> > /sites/client2/Page1.html
> > /sites/javafiles/Page1.java
> >
> > in order to keep html for one site separate from html for another and
> > both separate from the shared java files?  I saw things hinting at
> > ways to separate html from java, but I'm not seeing an example.
> >
> > Thanks again,
> > -Mike
> >
> > On Jul 26, 2007, at 10:32 PM, Igor Vaynberg wrote:
> >
> > > search wiki for variants and styles
> > >
> > > -igor
> > >
> > >
> > > On 7/26/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > >>
> > >> Hi, I'm considering using Wicket (or one of the many similar
> > >> frameworks) to augment or replace a homegrown framework.  The company
> > >> I work for creates many websites with similar functionality, but
> > >> completely different look and feel (we do online promotions for a
> > >> variety of clients).  Historically we've done this using a system of
> > >> servlets and ejbs that are shared across all sites that we host.  We
> > >> then use site-specific jsp so that we can customize the look and feel
> > >> of the website for the client.  All sites are then hosted off a
> > >> single server farm using different URL paths/parameters to
> > >> distinguish the site that should be shown.
> > >>
> > >> I'm trying to find a way to do something similar in Wicket or any of
> > >> the other frameworks but haven't found anything that really sounds
> > >> like what I'm looking for.  Is it possible to use a single Wicket
> > >> WebPage implementation with multiple HTML/CSS/Image "skins"?  Ideally
> > >> we would also be able to extend the base java WebPage to customize it
> > >> for a specific website as well.
> > >>
> > >> Any points/documentation on how to do this type of thing would be
> > >> greatly appreciated.
> > >>
> > >> Thanks,
> > >> -Mike
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >> For additional commands, e-mail: [EMAIL PROTECTED]
> > >>
> > >>
> >
> >
> >
> > --
> > Mike Comb
> > Director of Engineering
> > SoftCoin, Inc
> > [EMAIL PROTECTED]
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>


-- 
Scott Swank
reformed mathematician

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

Reply via email to