Accessing Spring beans inside wicket
While having fun implementing a checkbox tree for categories, I realized that I needed to access a spring service from outside of the Wicket Page/Component, from some Model classes that were being used to retrieve data for the tree.
I added the following to my RootTreeNode, but alas, my bean did not get set. I suspect that this annotation only works for Wicket pages/components.
@SpringBean(name = "categoryService") protected CategoryService categoryService;
Alas, how can I get to my spring bean while deep in my tree model? I read through the docs on wicket/spring, and the main gem that I found was to not hold a reference to my spring bean from inside my components. If my model classes are serialized with my component, I would not want to hold a reference to my bean inside the model.
I decided what I am going to do, I am going to pass a reference from my component to the model. If the model needs a spring bean, it can refer back to the component to get it. This way, I don't hold references to the spring bean.

Comments
Post new comment