Thanks again for the response. For the first part I had it already figured out, but having a concrete example is always helpful.

> We thought the same - but this not manageable with more than 50 files in one folder. So we decide to use folders - as already mentioned. Perhaps I'll write a tutorial...

How did you manage relative links in markup? With css resources it won't be a problem, the designers can add their resources using <link href="../css/style.css"></link> and any relative url in it will translate to the right path, however this is not true for relative paths inside the html document: <img src="../img/img.png" /> for example, will be a problem since wicket always resolves relatives paths from the web root (or webapp folder).

Do you include the resources you need inside all of your folders so relative paths resolve correctly outside and inside the wicket application?


Thanks in advance,
Edgar Merino


On 05/12/12 10:56, Jan Riehn wrote:
Hello Edgar,

> I think I'm missing something: since every WebPage in wicket has straight access to resources located in the web root (that is, every path reference in the page's markup is relative to the web root)

Wicket is able to locate resources outside of the web application: This could be done by implementing an own IResourceFinder:

public final class FileSystemResourceFinder implements IResourceFinder {
    private final Resource resource;

    public FileSystemResourceFinder(Resource resource) {
        this.resource = resource;
    }

    @Override
    public IResourceStream find(Class<?> clazz, String pathname) {
        try {
            final File file = new File(resource.getFile(), pathname);
            if (file.exists()) {
                return new FileResourceStream(file);
            }
        } catch (final IOException e) {
            // ignore, file couldn't be found
        }
        return null;
    }
}

At least you've to add the resource finder to the resource finders list with getResourceSettings().setResourceFinders(resourceFinderList) in your applications init method. Alternatively, implement a custom ResourceStreamLocator. At first the Locator should use the FileSystemResourceFinder - if there's no match the locator should fallback to wicket's default resource finder. So far, your application is able to locate resources from the local file system.

> I would like to avoid using folders to organise html files so the designers can put all the resources they need in their root folder. The mechanism you describe, seems to use folders, how are you managing this for the designers?

We thought the same - but this not manageable with more than 50 files in one folder. So we decide to use folders - as already mentioned. Perhaps I'll write a tutorial...


Best regards,

Jan


On 12/05/2012 02:49 PM, Edgar Merino wrote:
Hello Jan, that seems like a good approach. However, I think I'm missing something: since every WebPage in wicket has straight access to resources located in the web root (that is, every path reference in the page's markup is relative to the web root), I would like to avoid using folders to organize html files so the designers can put all the resources they need in their root folder. The mechanism you describe, seems to use folders, how are you managing this for the designers?


Edgar Merino


On 04/12/12 04:15, Jan Riehn wrote:
Hello Edgar,

Yes, this is how it works.

For the best separation of the responsibilities, you may store the resources outside of the web application (Think about a complete physical separation). We've made a good experience to break-off with wicket's given package structure - wicket’s resource localization does not fit with a separation of the responsibilities: the web designer has no knowledge about the internal package structure and it's not resistant against refactoring. Therefore, we use a more technical mechanism based on style, variation locale and the filename.

1. <prefix>/<style>/<variation>/<locale>/<filename>.<extension>
2. <prefix>/<style>/<variation>/<filename>.<extension>
3. <prefix>/<style>/<filename>.<extension>
4. <prefix>/<filename>.<extension>
5. <filename>.<extension>


Best regards,

Jan

On 12/04/2012 09:04 AM, Edgar Merino wrote:
Hello, I would like our designers to work with a simple folder structure
on our application pages markup, and we would like to avoid including
java source code files with the files we share with them. What is the
best way to do this? I though about implementing a custom
ResourceStreamLocator, so I can for instance name our html files using
the fqcn e.g. my.company.HomePage.html and placing these files in the
default package (under src/main/html for example).

Is this the way to go?

Thanks in advance,
Edgar Merino

---------------------------------------------------------------------
To unsubscribe, e-mail:users-unsubscr...@wicket.apache.org
For additional commands, e-mail:users-h...@wicket.apache.org





Reply via email to