Ned Collyer wrote:
> 
> There are a few ways to approach this, ie, having some class loader which
> resolves given string "class references", and those strings are wired in
> through spring.  This works - but feels a bit hacky.
> 

I don't know why you feel this hacky. It looks clean and easy to me:

public class TestPage extends WebPage {
        @SpringBean(name = "config")
        private Config config;

        public TestPage() {
                add(PanelFactory.getPanel(config, "testPanelOne"));
        }
}

public class PanelFactory {
        public static Panel getPanel(Config config, String id) {
                Class<? extends Panel> c =
Class.forName(config.getPanelClass()).asSubclass(Panel.class);
                Constructor<? extends Panel> constructor = 
c.getConstructor(String.class);
                return constructor.newInstance(id);
        }
}



-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA
-- 
View this message in context: 
http://www.nabble.com/Accessing-prototype-scoped-panel-beans-using-%40SpringBean-annotation-tp15627974p15648766.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to