You can use spring to inject the service, using @SpringBean and calling in the constructor InjectorHolder.getInjector().inject(this); (or use salve)
Service locator is also a possibility. That is why we left it open :) Martijn On Mon, Jul 27, 2009 at 2:20 PM, David Chang<david_q_zh...@yahoo.com> wrote: > > Hello, I am reading <<Wicket in Action>> to learn Wicket. The example on Page > 99 is about teaching detachable models. Here it goes: > > ----------- > public class CheeseModel extends Model { > private Long id; > private transient Cheese cheese; > public CheeseModel() { > } > public CheeseModel(Cheese cheese) { > setObject(cheese); > } > public CheeseModel(Long id) { > this.id = id; > } > �...@override > public Object getObject() { > if(cheese != null) return cheese; > if(id == null ) { > cheese = new Cheese(); > } else { > CheeseDao dao = ... > cheese = dao.getCheese(id); > } > return cheese; > } > �...@override > public void setObject(Object object) { > this. cheese = (Cheese)object; > id = (cheese == null) ? null : cheese.getId(); > } > �...@override > public void detach() { > this. cheese = null; > } > } > ----------- > > I would like to know how dao is obtained as indicated as follows: > > CheeseDao dao = ... > > Use a locator pattern? Or should I let CheeseModel extend a custom model in > which dao is set via Spring? Does the latter way create more memory > footprint? What are the effective ways of getting DAO avaiable to wicket > models? > > Thanks for your input! > > Cheers! > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.5 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org