On Mon, Jul 27, 2009 at 2:58 PM, David Chang <david_q_zh...@yahoo.com>wrote:
> > Martin and all, thanks for your input. > > >>You can use spring to inject the service, using @SpringBean and > calling in the constructor InjectorHolder.getInjector().inject(this); > (or use salve) > > You mean add a member to this CheeseModel class and use @SpringBean to > inject it? From reading this book, I know it works. How about creating a > super custom model (implements IModel) which has DAO ready and other classes > such as CheeseModel simply extends it? > > What do you mean by "salve"? http://code.google.com/p/salve/ Maarten > > > Thanks. > > > > --- On Mon, 7/27/09, Martijn Dashorst <martijn.dasho...@gmail.com> wrote: > > > From: Martijn Dashorst <martijn.dasho...@gmail.com> > > Subject: Re: the effective ways of wicket models to access database > > To: users@wicket.apache.org > > Date: Monday, July 27, 2009, 8:29 AM > > 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 > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >