You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by James Perry <ja...@gmail.com> on 2007/10/19 17:40:39 UTC

Best practises and advice for integrating Wicket with Spring

Dear Wicket community,

What are the best practises and advice for integrating Wicket with Spring. I
have read the Wiki so I'm aware of injecting Spring's beans using
annotations. I am also interested to know if I should just keep an Spring
ApplicationContext in Wicket's Application class, inject the proxy-based
Service POJOs into the Application or just inject them into each component
that needs to use my service's methods?

Look forward to your advice,
James.

Re: Best practises and advice for integrating Wicket with Spring

Posted by Igor Vaynberg <ig...@gmail.com>.
but can you do

class EntityModel extends LoadableDetachableModel {
  @Injectable private SessionFactory sf;
  private Class clazz;
  private Serializable id;

  pulblic(Class clazz, Serializable id) { this.clazz=clazz; this.id=id; }
  public Object load() {
    return sf.currentSession().load(clazz, id);
  }

   // for testing
   public void setSessionFactory(SessionFactory sf) { this.sf=sf; }
}

add(new UserEditorPanel("editor", new EntityModel(User.class, 15L)));

with salve.googlecode.com you can! :)

-igor

On 10/19/07, kent lai <ma...@virtuallyonline.net> wrote:
> My personal practice has been to abstract the bean lookup with an
> interface called bean locator, and then create a subclass
> implementing it with ApplicationContextAware. Then inject that class
> into my WebApplication. Then my application looks up the required
> bean from the WebApplication's bean locator class.
>
> My bean locator also customized the lookup via class type (since I
> don't really have multiple classes of the same 'type')
>
> Guess I just liked to keep my pages lean...
>
>
> On 19 Oct 2007, at 11:40 PM, James Perry wrote:
>
> > Dear Wicket community,
> >
> > What are the best practises and advice for integrating Wicket with
> > Spring. I
> > have read the Wiki so I'm aware of injecting Spring's beans using
> > annotations. I am also interested to know if I should just keep an
> > Spring
> > ApplicationContext in Wicket's Application class, inject the proxy-
> > based
> > Service POJOs into the Application or just inject them into each
> > component
> > that needs to use my service's methods?
> >
> > Look forward to your advice,
> > James.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Best practises and advice for integrating Wicket with Spring

Posted by kent lai <ma...@virtuallyonline.net>.
My personal practice has been to abstract the bean lookup with an  
interface called bean locator, and then create a subclass  
implementing it with ApplicationContextAware. Then inject that class  
into my WebApplication. Then my application looks up the required  
bean from the WebApplication's bean locator class.

My bean locator also customized the lookup via class type (since I  
don't really have multiple classes of the same 'type')

Guess I just liked to keep my pages lean...


On 19 Oct 2007, at 11:40 PM, James Perry wrote:

> Dear Wicket community,
>
> What are the best practises and advice for integrating Wicket with  
> Spring. I
> have read the Wiki so I'm aware of injecting Spring's beans using
> annotations. I am also interested to know if I should just keep an  
> Spring
> ApplicationContext in Wicket's Application class, inject the proxy- 
> based
> Service POJOs into the Application or just inject them into each  
> component
> that needs to use my service's methods?
>
> Look forward to your advice,
> James.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Best practises and advice for integrating Wicket with Spring

Posted by Scott Swank <sc...@gmail.com>.
Have you looked at the phonebook example app?  It's a demo application
using Wicket, Spring & Hibernate.

http://cwiki.apache.org/WICKET/wicket-phonebook.html

On 10/19/07, James Perry <ja...@gmail.com> wrote:
> Dear Wicket community,
>
> What are the best practises and advice for integrating Wicket with Spring. I
> have read the Wiki so I'm aware of injecting Spring's beans using
> annotations. I am also interested to know if I should just keep an Spring
> ApplicationContext in Wicket's Application class, inject the proxy-based
> Service POJOs into the Application or just inject them into each component
> that needs to use my service's methods?
>
> Look forward to your advice,
> James.
>


-- 
Scott Swank
reformed mathematician

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Best practises and advice for integrating Wicket with Spring

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Fri, 19 Oct 2007, James Perry wrote:
> annotations. I am also interested to know if I should just keep an Spring
> ApplicationContext in Wicket's Application class, inject the proxy-based
> Service POJOs into the Application or just inject them into each component
> that needs to use my service's methods?

We have found it clearer to inject to each component,
otherwise each component gets a dependency to the Application
subclass which in turn gets dependencies to all services.

And you can easily inject to many non-Component classes, too

public class MyModel implements IModel {
    @SpringBean(id = "myDao") private MyDao myDao;

    public MyModel() {
    	InjectorHolder.getInjector().inject(this);
    }
    ...
}

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org