and you have to have the pages defined as beans in the application
context? with their properties specified?
-Igor
On 11/7/05, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
>
> but how does the above handle deserealization of pages? there is
nothing
> to reinject the dependencies.
>
> -Igor
>
>
> On 11/7/05, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote:
> >
> > IMHO pages are standing on the borderline between a stateful GUI and
> > the rest of the application in form of stateless services.
> > DI should be done by the IoC container, creating the pages can
better
> > be done the standard Wicket way (e.g. with PageParameters).
> >
> > As described before I'm using a custom page factory that cooperates
> > with a wrapped page factory and the containing bean factory:
> >
> > public class SpringInjectingPageFactory implements IPageFactory,
> > BeanFactoryAware {
> >
> > private AutowireCapableBeanFactory beanFactory;
> > private IPageFactory pageFactory;
> >
> > public void setPageFactory(IPageFactory pageFactory) {
> > this.pageFactory = pageFactory;
> > }
> >
> > public void setBeanFactory(BeanFactory beanFactory) throws
> > BeansException {
> > this.beanFactory = (AutowireCapableBeanFactory)beanFactory;
> > }
> >
> > public Page newPage(Class pageClass) {
> > Page page = this.pageFactory.newPage(pageClass);
> >
> > injectDependencies(page, pageClass.getName ());
> >
> > return page;
> > }
> >
> > public Page newPage(Class pageClass, PageParameters parameters) {
> > Page page = this.pageFactory.newPage(pageClass, parameters);
> >
> > injectDependencies(page, pageClass.getName ());
> >
> > return page;
> > }
> >
> > private void injectDependencies(Page page, String beanName) {
> > if (this.beanFactory.containsBean(beanName)) {
> > this.beanFactory.applyBeanPropertyValues(page, beanName);
> > }
> > }
> > }
> >
> > Note that if you don't specify a name or id attribute for beans,
they
> > will be registered under their classname in Spring.
> > And NO, I don't use autowiring: applyBeanPropertyValues() does not
> > autowire although it is located in AutowireCapableBeanFactory.
> >
> > Sven
> >
> > >you are right, this is not ioc. but are pages/components managed by
> > an ioc
> > >container?
> > >-Igor
> > >
> > >
> > >On 11/6/05, Alexandru Popescu <
[EMAIL PROTECTED]>
> > wrote:
> > >>
> > >> #: Igor Vaynberg changed the world a bit at a time by saying on
> > 11/6/2005
> > >> 7:06 PM :#
> > >> > Or how about a simple solution:
> > >> >
> > >> > public MyApplication extends WebApplication {
> > >> > public Object lookup(String name) {
> > >> > Object=...do a lookup from somewhere like spring context or app
> > >> object...;
> > >> > return object;
> > >> > }
> > >> > }
> > >> >
> > >> > public MyPage extends Page {
> > >> > public transient SomeService service;
> > >> >
> > >> > public SomeService getService() {
> > >> > if (service==null) {
> > >> > service=getApplication().lookup(SomeService.class.getName());
> > >> > }
> > >> > return service;
> > >> > }
> > >> >
> > >> > I know its not quiete as elegant as ioc but it has none of the
> > >> performance
> > >> > hits an automatic injection would cause if it would be done on
> > >> > deserialization of every component. Also its a lazy lookup so
you
> > dont
> > >> do it
> > >> > until its needed, and its only done once per page (until it
gets
> > >> > deserialized).
> > >> >
> > >> > -Igor
> > >> >
> > >>
> > >> But this was exactly what I was suggesting to avoid ;-). Lookups
> > and
> > >> factories are not ioc/di.
> > >>
> > >> ./alex
> > >> --
> > >> .w( the_mindstorm )p.
> > >>
> > >>
> > >>
> > >> -------------------------------------------------------
> > >> SF.Net email is sponsored by:
> > >> Tame your development challenges with Apache's Geronimo App
Server.
> > >> Download
> > >> it for free - -and be entered to win a 42" plasma tv or your very
> > own
> > >> Sony(tm)PSP. Click here to play:
> > http://sourceforge.net/geronimo.php
> > >> _______________________________________________
> > >> Wicket-user mailing list
> > >> Wicket-user@lists.sourceforge.net
> > >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >>
> >
> >
> > -------------------------------------------------------
> > SF.Net email is sponsored by:
> > Tame your development challenges with Apache's Geronimo App Server.
> > Download
> > it for free - -and be entered to win a 42" plasma tv or your very
own
> > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
> > _______________________________________________
> > Wicket-user mailing list
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
>
>