On 10/7/05, Johan Compagner <[EMAIL PROTECTED]> wrote:
> don't see exactly what you are trying to do.
>
The code is part of AutoLinkResolver. Lets assume the following markup
<wicket.link autolink=true>
<link ... href="myScript.js"/>
</wicket:link>
For previewability reasons myScript.js must be in the package, and at
runtime href URL must be converted into
/resources/<scope>/myScript_<style>_<locale>.js depending on users
actuall style, variation and locale.
> why do you want the locale to tbe taken into account?
> the file is not there so it can't serve it anyway.
>
because the user might have style or locale dependent js scripts.
the files are in the package
> You do want a package resource that has a href that has a locale which
> points to a file lets say:
>
> foo_De.bar which even isn't there? because only foo.bar is there?
yes. Like we always handle i18n resources, correct?
>
> i think simplifing this will be hard.This is there because of all the
> locales that where in the name of all the files.
>
Actually I was thinking about another approach which I think has been
discussed on the list a couple of weeks ago as well.
WebRequestCycle.parseRequest() parses the URL to determine how to
react on it. I was thinking about extending it and to allow for user
extensible handling. A possible user implementation might look like
/**
* Subclasses may implement there own strategies to return static
content.
* The default implementation only returns css and js files matching
the url
* path and found by the class loader.
*
* @return 1 - returning a page; 2 - static content (no Page); else -
not found
*/
protected int doParseRequest()
{
final String path = Strings.beforeLast(request.getPath(),
'.').substring(1);
final String extension = '.' +
Strings.afterLast(request.getPath(), '.');
if (".css".equalsIgnoreCase(extension) ||
".js".equalsIgnoreCase(extension))
{
final IResourceStream stream = new
ClassLoaderResourceStreamLocator().locate(
getClass().getClassLoader(), path,
session.getStyle(),
session.getLocale(),
extension);
if (stream != null)
{
final Resource resource = new Resource()
{
private static final long
serialVersionUID = 1L;
public IResourceStream
getResourceStream()
{
return stream;
}
};
resource.onResourceRequested();
// Found static resource
return 2;
}
}
// Did not found the resource
return 0;
}
It is only an example. I personally wouldn't like to expose the
package structure to the user, it is only to show what would be
possible. It would go last after all our current url parsing has
finished and thus wouldn't require any changes to any existing
application but would give users more possibilities to extend url
handling. What do you think?
Juergen
>
>
> On 10/7/05, Juergen Donnerstag <[EMAIL PROTECTED]> wrote:
> >
> > I'm not sure I do it the right way. I'd like to reference a file
> > (href) which has a name that does not have the locale nor the style,
> > but during runtime the locale and style should be taken into account.
> > Provided the code below is right, I have to set the locale and style 3
> > times. Isn't there a simpler way to do it? Eventually the
> > reference.getPath will replace the href attribute.
> >
> > final SharedResources sharedResources =
> getApplication().getSharedResources();
> > Resource resource = PackageResource.get(clazz, href, getLocale(),
> getStyle());
> > sharedResources.add(clazz, href, getLocale(), getStyle(), resource);
> >
> > // Create the component implementing the link
> > resourceReference = new
> PackageResourceReference(getApplication(), clazz, href);
> > resourceReference.setLocale(getLocale());
> > resourceReference.setStyle(getStyle());
> >
> > Juergen
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by:
> > Power Architecture Resource Center: Free content, downloads, discussions,
> > and more. http://solutions.newsforge.com/ibmarch.tmpl
> > _______________________________________________
> > Wicket-develop mailing list
> > [email protected]
> >
> https://lists.sourceforge.net/lists/listinfo/wicket-develop
> >
>
>
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop