Hi, Unfortunately I'm using this functionality only in my test application to check how does these all "spring things" work in Wicket. So probably I can't help you much. One thing about a prototype-scoped beans, which is interesting. I have a very simple bean class to test injection:
package example.spring; public class SimpleBean { private static int counter = 0; private String welcome; public SimpleBean() { this.welcome = "Welcome text from a default constructor: " + (++counter); System.out.println("Constructor A - " + counter); } public SimpleBean(String welcome) { this.welcome = welcome + " " + (++counter); System.out.println("Constructor B - " + counter); } public String getWelcome() { return welcome; } } I've created a static counter to check how many instances of this class is created and simple output to observe bean creation. In my applicationContext.xml there is an entry: <bean id="simpleBean" class="example.spring.SimpleBean" scope="prototype"> <constructor-arg> <value>This is a sample welcome text for Spring bean</value> </constructor-arg> </bean> And I inject this bean into my MyTestPage: @SpringBean private SimpleBean simpleBean; public MyTestPage() { super(); System.out.println(simpleBean.getWelcome()); } When I enter this page first time in a browser there is the following output: Constructor B - 1 Constructor A - 2 Constructor B - 3 This is a sample welcome text for Spring bean 3 So as you can see there are 3 calls to SimpleBean constructor, including one default constructor call (so it looks like 3 instances of this class was created). Each time I enter MyTestPage SimpleBean counter is incremented three times: Constructor B - 4 Constructor A - 5 Constructor B - 6 This is a sample welcome text for Spring bean 6 etc... The question is: is it a normal behaviour or a bug in wicket-spring-annot (or somewhere in my code :))? When I comment a default no-argument constructor code, I've received an error: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:718) at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:499) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216) at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285) at org.apache.wicket.proxy.LazyInitProxyFactory.createProxy(LazyInitProxyFactory.java:138) at org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:102) at org.apache.wicket.injection.Injector.inject(Injector.java:109) at org.apache.wicket.injection.ConfigurableInjector.inject(ConfigurableInjector.java:40) at org.apache.wicket.injection.ComponentInjector.onInstantiation(ComponentInjector.java:54) at org.apache.wicket.Application.notifyComponentInstantiationListeners(Application.java:919) at org.apache.wicket.Component.<init>(Component.java:606) at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:111) at org.apache.wicket.Page.<init>(Page.java:195) at org.apache.wicket.markup.html.WebPage.<init>(WebPage.java:99) Is a "null constructor" necessary for "bean" class? BTW: In Wicket 1.2.6 prototype-scoped beans does not work. I was wrong in my last mail, it seems that they work as singletons. Best regards, Daniel Rüdiger Schulz wrote: > Hello, > > I can't say anything about request or session scoped beans. > But I am interested in how you use prototype-scoped beans. Do you use > them to store the state of your Wicket-components? I have some > problems with that (which I posted earlier)... ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user