Since the original question was about storing component references as class members, let me answers how we handle that in our shop.

Wicket serializes stateful pages anyway, so any component references within the page don't hurt (at all). It's just a 4-byte reference to an object wicket already references (through the component hierarchy). As for stateless pages it matters even less, as they are not serialized at all (so only a 4-byte reference per component uses some memory).

I think the most important rules regarding serialization are:
- don't reference other pages or components within those pages
- don't reference large object (use loadable detachable models instead)

Like an earlier reponse to this question said: referencing components by their (string) id within the page is quite ugly. not to mention it breaks quite easily.

We use component references extensively (e.g. when the visibility of one component depends on the state others), and have never encountered any problems.

Met vriendelijke groet,
Kind regards,

Bas Gooren

schreef meduolis op 8-11-2013 17:20:
The only thing I googled related to "final" and wicket is this:

7. Java nuances — There are two Java nuances that catch many Wicket
newcomers off-guard.


1. The first is serialization. Wicket uses Java serialization to store the
state of your component hierarchy (the page and all its components and their
components and so-on) in memory or on disk between page requests. This means
you need to be careful because things can get serialized by accident. The
most common cause of this is declaring a variable "final" outside of an
anonymous inner class and then using it inside that anonymous inner class.
Doing this causes the compiler to add a member variable to the anonymous
inner class. If that final variable is a large collection or a service from
your middle-tier, this can cause a gigantic explosion of memory usage and
can be hard to track down. In short: be very cautious with what you
reference within anonymous inner classes and use member variables in your
classes sparingly.


source:
http://wickettraining.com/ten-things-every-wicket-programmer-should-know.html



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-Components-as-Class-Members-tp4662235p4662237.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Reply via email to