You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Uwe Schäfer <sc...@thomas-daily.de> on 2007/12/05 20:14:37 UTC

getApplication

Hi

why is it, that i can (and should) override getSession() to get 'my' 
implementation,

     @Override
     public MySession getSession()
     {
         return (MySession) super.getSession();
     }

whereas getApplication is unfortunately final.

     @Override
     public final Application getApplication()
     {
         return Application.get();
     }

What am i missing?

cu uwe

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


Re: getApplication

Posted by Eelco Hillenius <ee...@gmail.com>.
> why is it, that i can (and should) override getSession() to get 'my'
> implementation,
>
>      @Override
>      public MySession getSession()
>      {
>          return (MySession) super.getSession();
>      }

Actually, if you use Java 5, I think this pattern is nicer:

public class MySession extends WebSession {

  ...
  public static MySession get() {
    return (MySession)Session.get();
  }
  ...

and then just do MySession s = MySession.get();

Eelco

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


Re: getApplication

Posted by Eelco Hillenius <ee...@gmail.com>.
On Dec 5, 2007 11:32 PM, Uwe Schäfer <sc...@thomas-daily.de> wrote:
> Martin Funk schrieb:
> > The Application you declare in the web.xml, so if you want your
> > MyApplication you do it there and no need to fiddle with the
> > getApplication() method.
>
> sorry, i did not make myself clear. i do declare my application in the
> web.xml. thats not what i am talking about. what i want here is
> typesafety without sprinkling my code with typecasts, but have one
> central cast in getApplication() of a base-page instead.

That's what my suggestion does.

Eelco

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


Re: getApplication

Posted by Martin Funk <fu...@arcor.de>.
Uwe Schäfer schrieb:
> Martin Funk schrieb:
>> The Application you declare in the web.xml, so if you want your 
>> MyApplication you do it there and no need to fiddle with the 
>> getApplication() method.
>
> sorry, i did not make myself clear. i do declare my application in the 
> web.xml. thats not what i am talking about. what i want here is 
> typesafety without sprinkling my code with typecasts, but have one 
> central cast in getApplication() of a base-page instead.
>
> cu uwe
hmmm...
for that case I don't have an elegant reasoning either and looking at 
the wide spread usage of Application.get() I wouldn't be suprised if 
there isn't any.

carpe diem,

Martin

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


Re: getApplication

Posted by Uwe Schäfer <sc...@thomas-daily.de>.
Martin Funk schrieb:
> The Application you declare in the web.xml, so if you want your 
> MyApplication you do it there and no need to fiddle with the 
> getApplication() method.

sorry, i did not make myself clear. i do declare my application in the 
web.xml. thats not what i am talking about. what i want here is 
typesafety without sprinkling my code with typecasts, but have one 
central cast in getApplication() of a base-page instead.

cu uwe


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


Re: getApplication

Posted by Martin Funk <fu...@arcor.de>.
Uwe Schäfer schrieb:
> Hi
>
> why is it, that i can (and should) override getSession() to get 'my' 
> implementation,
>
>     @Override
>     public MySession getSession()
>     {
>         return (MySession) super.getSession();
>     }
>
> whereas getApplication is unfortunately final.
>
>     @Override
>     public final Application getApplication()
>     {
>         return Application.get();
>     }
>
> What am i missing?
>

The Application you declare in the web.xml, so if you want your 
MyApplication you do it there and no need to fiddle with the 
getApplication() method.

my2ct

Martin

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