we can write a traversal for setters, but i really dont see value in it, what is your setter going to do - stick it into some private field.

as far as afterPropertiesSet() callback, you already have it - it is the constructor of the component with @SpringBean annots :)

-Igor


On 3/20/06, Tom van Zummeren <[EMAIL PROTECTED]> wrote:

Ok thanks,

 

By the way, is this the best way to inject dependencies? It works like a charm but it isn't Spring-like to inject a dependency with only a private field. Spring normally uses a setter to do so, and if the bean implements InitializingBean it calls the afterPropertiesSet() method afterwards (to do some validation of the just set dependencies)

Is there an option to do it like this?

 

Tom

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Igor Vaynberg


Sent: Monday, March 20, 2006 5:17 PM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] New features Wicket 1.2

 

there is more info here:

http://www.wicket-wiki.org.uk/wiki/index.php/Spring

-Igor

On 3/20/06, Johan Compagner <[EMAIL PROTECTED]> wrote:

One warning don't do this:



@SecuredWicketPage public class EditAccountPage extends Template{
    private String repeatedPassword;

    @SpringBean   

    private AccountService accountService = null;



    public EditAccountPage() {
        Form form = new Form("form", new CompoundPropertyModel(this)) {

(the = null)

Because then youre accountService will be null again when the page is fully constructed.


johan




On 3/20/06, karthik Guru <[EMAIL PROTECTED]> wrote:

> Spring support for injecting your business logic into your web pages in a non-intrusive manner, while still being able to use the
> convenient Wicket idiom for creating pages (using the Java
new operator).

Yes - this one is my favourite! . ..actually even IAuthorizationStrategy and Ajax support rocks.!..now am not sure which is the best 1.2 feature. May be we s'd have a vote :)

You can inject spring-ified objects into your page / components just by specifying an annotation @SpringBean. Then wicket-spring module takes care of resolving all those dependencies when the component is instantiated.
It does it by using the cool 1.2 feature that allows you to register as many IComponentInstantiationListener as you want.
These listeners get called when the component is instantiated.

wicket-spring registers a IComponentInstantiationListener that runs through your page/components looking for fields that require injecttion (the ones that have @SpringBean specified) and resolves them through Spring's ApplicationContext.

So you just do this -

@SecuredWicketPage public class EditAccountPage extends Template{
    private String repeatedPassword;

    @SpringBean   
    private AccountService accountService;

    public EditAccountPage() {
        Form form = new Form("form", new CompoundPropertyModel(this)) {



and by the time you actually get to use accountService, wicket w'd have already resolved it for you with the help of Spring...and as you can see its all non-intrusive (yeah as long as you are ok with specifying @SpringBean :)) )

wicket team rocks!! - and in this case igor & eelco.. ..great job!




On 3/20/06, Tom van Zummeren <[EMAIL PROTECTED]> wrote:

I was wondering if there are any examples yet of new features in Wicket 1.2

 

Because on the wicket site I saw a list of new features in Wicket 1.2, but it didn't say how the new features are implemented.

In this case I'd like to know the following:

 

Spring support for injecting your business logic into your web pages in a non-intrusive manner, while still being able to use the convenient Wicket idiom for creating pages (using the Java new operator).

 

What is this non-intrusive manner?

 

 

Tom

 

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.2.5/284 - Release Date: 3/17/2006



--

-- karthik --



 

--
No virus found in this incoming message.

Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.2.5/284 - Release Date: 3/17/2006


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.2.5/284 - Release Date: 3/17/2006


Reply via email to