try the below

 application.addComponentInstantiationListener(new
SpringComponentInjector(application, context));

-igor


On 1/5/07, tooy li(Gmail) <[EMAIL PROTECTED]> wrote:

I try the code depends on the wiki's spring post, but it cannot inject the
springbean well.

I trace the source code of AnnotApplicationContextMock and wickeTester ,
and find it cannot really register a Injector into the
componentInstantiationListeners of component class . I think i can add this
one in the wicketTeser's DummyWebApplication, it' work well.

below is my code. it had spent me more than 4 hours, i'm so stupid.  Is
there anyone can give some adivce how to use the
AnnotApplicationContextMock  correctly?

public static WicketTester createWicketTester(Class pageClass) {
  AnnotApplicationContextMock appctx = new AnnotApplicationContextMock();
  ApplicationContext context = CoreServiceLocator.getInstance
().getAppContext();

  Field[] fields = pageClass.getDeclaredFields();
  for (int i = 0; i < fields.length; i++) {
     SpringBean bean = fields[i].getAnnotation(SpringBean.class);
     appctx.putBean(bean.id(), context.getBean(bean.id()));
  }

  DummyWebApplication application = new DummyWebApplication();
  application.addComponentInstantiationListener(new ComponentInjector());
  return new WicketTester(application);
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to