Ah, yes. A child class which overrides the method and is "protected" will complain that visibility is reduced ... Have to wait for Wicket.next.
On Wed, Sep 14, 2011 at 2:30 PM, Peter Ertl <[email protected]> wrote: > @Martin: > > yeah, switching from protected to public should at most yield a warning in an > overloaded class. Igor didn't like it. Maybe my English confused him and he > thought about going from public to protected?! > > Would be great if we could change this in 1.5. > > What you think? > > > > Am 14.09.2011 um 13:17 schrieb Martin Grigorov: > >> On Wed, Sep 14, 2011 at 2:07 PM, Peter Ertl <[email protected]> wrote: >>> >>> 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 :-) >> I think 'protected' -> 'public' is not a problem. >> The opposite ('public' -> 'protected') is not allowed in 1.5.x. >>> >>> 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: [email protected] >>> For additional commands, e-mail: [email protected] >>> >>> >> >> >> >> -- >> Martin Grigorov >> jWeekend >> Training, Consulting, Development >> http://jWeekend.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] > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
