I have seen an application (not mine!) fail horribly and costly on the second example.

The problem with getting an object from the session and passing the reference to a (Compound)PropertyModel is that the natural assumption, the session object is updated too, is wrong. So this is exactly the same problem as keeping a reference to the session itself, only now restricted to less data.

Regards,
   Erik.




Op 22-11-10 20:51, Igor Vaynberg schreef:
no. the example below doesnt hit any pitfalls because it doesnt
reference the session itself. as long as objects retrieved from
session do not contain references back to session he is ok.

however, declaring Session instance as final is not a good idea
because it makes it easy to reference it in anonymous classes.

-igor

On Mon, Nov 22, 2010 at 11:49 AM, Erik van Oosten<e.vanoos...@grons.nl>  wrote:
Yes, both are very wrong.

Pitfalls are in earlier messages in this thread.


On 22-11-10 16:36, mzem...@osc.state.ny.us wrote:
By "keep a reference to the session in their class" do you mean something
like this?

Are there any pitfalls to doing this?

final Session session = getSession();
add(new Label("userNameLabel", new Model(session.getUser
().getUserName())));

How about this?
final UserDTO dto = session.getUser();
CompoundPropertyModel cpm = new CompoundPropertyModel(dto);


--
Sent from my SMTP compliant software
Erik van Oosten
http://day-to-day-stuff.blogspot.com/



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

Reply via email to