On Wed, May 9, 2012 at 3:24 PM, Martijn Dashorst <[email protected]> wrote: > There are a couple of reasons: > > It adds bloat. Nobody (afaik) really likes these methods, as almost > the same functionality can be achieved by using Application.get() or > Session.get(); > > The only reason to provide these short hand methods is to allow > binding using property models. For example new PropertyModel(this, > "session.user.name"); > > By opening up these methods for overriding, the contract is gone. > Components can't rely on the fact that getApplication() does just > that.
But what else you can return ? Java would allow you to return more specific Application class (aka covariant) or... null. But this is my stupid code after all. I can return 'null' in getMyApplication() as well if I want ... Currently WebMarkupContainer tries to be nice by providing getWeb**() variants of getRequest, getResponse, getSession, getPage. I find them nice because 99% of the times I need WebResponse/WebRequest instead of Response/Request. But those methods as you said are completely new, i.e. there are additional entries in the class's methods table. > > The use case you present for doing so is rather thin: there is nothing > preventing you from creating a getMyApplication() method that has the > correct type (as you already say you want to provide the correct type > in your own base classes—just create your own method that has the > correct type). > > Martijn > > On Wed, May 9, 2012 at 1:51 PM, Christoph Leiter > <[email protected]> wrote: >> Hi, >> >> Component#getApplication() is currently final. Could it be made non-final so >> that I can make use of covariant return types in my base page? >> Component#getSession() - which works the same way - is already non-final. >> >> A similar case could be made for Component#getPage() (which I would override >> in my base panel). >> >> Would that be a bad idea for some reason? >> >> >> Christoph > > > > -- > Become a Wicket expert, learn from the best: http://wicketinaction.com -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com
