java 4: MySession mySession = (MySession)Session.get();

java5: MySession mySession = MySession.get();

(add a get() method on your MySession object)

johan


On 3/6/07, Jason Roelofs <[EMAIL PROTECTED]> wrote:

On 3/6/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote:

> > First, it looks as if I'm supposed to define my own session
>
> You can, you don't have to.
>
> >, which I guess I
> > can do (wrapper around getAttribute and setAttribute). First, why?
>
> Because it is type safe. Instead of User u =
> (User)session.get("_theUser"); you simply do User u =
> session.getUser(). This makes it obvious what can be in your session
> at any giving time, and refactoring etc will be easy.
>
> What's
> > wrong with the default set/getAttribute(String, String) being public
> and
> > saving to a Hash of some sort?
>
> If you want that, provide your own session and expose those methods
> yourself. We don't provide it because we think it is bad programming
> practice.
>
> > Second, how do I set up Application to use
> > this new custom Session of mine?
>
> override newSession and return your session object there. The method
> will be called by Wicket.
>
> Maybe the above is moot, here's my situation. I have a list of Users,
> > individually selectable. I want, when a User is selected, to put that
> User
> > object (hibernate Entity) or just it's Id into the session (something)
> for
> > further use. Some pages can only be accessed when you've selected a
> User to
> > use.
> >
> > Is there a right way of doing this? A wrong way?
>
> You could do that. Though it might be better if you made the contract
> of having a user more explicit e.g. by requiring it (or it's id) as a
> constructor argument in other pages or components. Your choice.
>
> Eelco
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user



So you're saying that I'm supposed to...

class MySession extends WebSession {
  private User selectedUser;

  public get/setUser() { ... }
}

And wicket will keep a single instance of this class in memory at all
times, so as not to lose my selected value? And how do I access my custom
version of the Session, from a Page, Component, etc,
((MySession)getSession())?

Jason



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to