Sure - if you never want to use a property model.  And if you don't use OGNL
anywhere in your application.  Say, for instance, Hibernate, etc....

You have to be careful how much you use it - I hated Tapestry because there
was so much OGNL littered throughout multiple files.  But, if you don't ever
use it, then you must create a custom model implementation for every single
property you ever want to display.  And your OGNL [1] is all in .java files,
so it gives you one place to search for expressions.  Also, some things are
less likely to ever be refactored.  In my opinion (FWIW),
"session.user.username" is unlikely to ever change - it's not likely you're
going to rename any of those variables since they are pretty universal.

To each his own - there's always tradeoffs to be made.

[1]- granted, this isn't truly "OGNL" - but you know what I mean - property
expressions.

-- 
Jeremy Thomerson
http://www.wickettraining.com


On Mon, Jul 28, 2008 at 6:09 PM, Ricky <[EMAIL PROTECTED]> wrote:

> Those paths are not "safe" and elegant IMHO.Should someone type in wrong
> path, then it would blow ... ==(
> I'd rather see a compile error than a runtime exception.
>
> Don't  you agree?
>
> Rick
>
> On Mon, Jul 28, 2008 at 4:25 PM, Maurice Marrink <[EMAIL PROTECTED]>
> wrote:
>
> > Yes, one of the ideas behind wicket is that you create your own custom
> > wicketsession to access your session objects in a typesafe way.
> >
> > Using a propertymodel like Jeremy showed is a very elegant way of
> > getting back that information.
> >
> > Maurice
> >
> > On Mon, Jul 28, 2008 at 9:39 PM, Jeremy Thomerson
> > <[EMAIL PROTECTED]> wrote:
> > > I'm not sure what all you're trying to make easier, but as far as
> > displaying
> > > the user - you could use this:
> > >
> > > new Label("username", new PropertyModel(this,
> "session.user.username"));
> > >
> > > --
> > > Jeremy Thomerson
> > > http://www.wickettraining.com
> > >
> > >
> > >
> > > On Mon, Jul 28, 2008 at 2:34 PM, insom <[EMAIL PROTECTED]> wrote:
> > >
> > >>
> > >> I'm trying to display a user's name in the browser. I'm using SWARM
> for
> > >> authentication. My general idea is that the user signs in with this
> > >> function:
> > >>
> > >> public boolean signIn(String username, String password) {
> > >>  LoginContext ctx = new FoodHandlerContext(username, password);
> > >>  MySession session = (MySession)getSession();
> > >>  session.login(ctx);
> > >>
> >
>  session.setUser(session.getFoodHandlerDAO().getUserByUsername(username));
> > >> }
> > >>
> > >> Then, when I need any information about the user, I get it in the
> > following
> > >> way:
> > >>
> > >> add(new Label(((MySession)getSession()).getUser().getUsername()));
> > >>
> > >> This works, but my sense of Wicket is that there's probably a better
> > "best
> > >> practice" for maintaining session objects like the User. My question
> is,
> > >> can
> > >> I leverage Wicket's structure to make session object management easier
> > than
> > >> I'm doing?
> > >> --
> > >> View this message in context:
> > >>
> > http://www.nabble.com/Getting-User-from-Session-tp18697696p18697696.html
> > >> Sent from the Wicket - User mailing list archive at Nabble.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]
> >
>

Reply via email to