Am 14.09.2011 um 09:32 schrieb nhsoft.yhw: > inputStream = packageResource.getCacheableResourceStream().getInputStream();
I think this needs some clarification... PackageResource has these methods for getting a stream: (1) protected IResourceStream getResourceStream() and (2) public IResourceStream getCacheableResourceStream() the intention is: - (1) locates the default resource without taking any client preferences into account. - (2) is there to get a client-specific resoure stream that is supposed to be immutable for the lifetime of the application and should be cached. the sooner (1) locates the resource stream based on - anchor class - name - locale - style - variation as specified in the constructor(!) of PackageResource. So for example when using CssResourceReference (which is a descendant of PackageResourceReference) like that in your page: private static final PackageResourceReference CSS = new CssResourceReference(MyPage.class, "mycss", Locale.ENGLISH, "style1", "variation1"); these parameters will be applied to PackageResource when resolving the reference and yield: - anchor class = MyPage.class - name = "mycss" - locale = Locale.ENGLISH - style = "style1" - variation = "variation1" and getResourceStream (1) will locate the resource based on the above criteria. In contrary getCacheableResourceStream (2) will override the values for locale and style with the values of the current session. - anchor class = MyPage.class - name = "mycss" - Session.getLocale() if not empty, otherwise Locale.ENGLISH - Session.getStyle() if not empty, otherwise "style1" - variation = "variation1" So (1) returns the default stream and (2) returns the stream fitting the client's preferences. Unfortunately I realized it too late that (1) which was 'public' in 1.4 is now 'protected' in 1.5. It's too late to change this without breaking the API. This can change in 1.6 to 'public' again unless things change completely (don't think so :-) So In case you need to access (1) but miss the 'public' I can suggest the following workaround / kludge. public class MyPackageResource extends PackageResource { public MyPackageResource(Class<?> scope, String name, Locale locale, String style, String variation) { super(scope, name, locale, style, variation); } // change access to public here public IResourceStream getResourceStream() { return super.getResourceStream(); } } If you only need to open a stream of a package located file use this instead - no need for PackageResource in that case at all: InputStream is = MyPage.class.getResourceAsStream("mycss.css") Cheers Peter --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org