You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by alex2008 <al...@yahoo.it> on 2008/08/03 11:07:03 UTC

Problem on external LoadableDetachableModel class

....
  @SpringBean
    private ProductManager productManager;
    //@Autowired
    public void setProductManager(ProductManager productManager) {
        this.productManager = productManager;
    }
.....
 LoadableDetachableModel personListModel = new LoadableDetachableModel() {
            @Override
            protected Object load() {
                return productManager.getProducts();
            }
        };
add(new ListView("products", personListModel) {
........
        });
It's ok. 


While if a use an external class:
package wicketapp.util;

import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import springapp.service.ProductManager;

public class ProductModel extends LoadableDetachableModel {
    @SpringBean
    private ProductManager productManager;
    //@Autowired
    public void setProductManager(ProductManager productManager) {
        this.productManager = productManager;
    }

    protected Object load() {
        return productManager.getProducts();
    }
}

..........
 ProductModel personListModel = new ProductModel();
        
        add(new ListView("products", personListModel) {
        .......
        });

It's wrong. 

Which is the problem?
-- 
View this message in context: http://www.nabble.com/Problem-on-external-LoadableDetachableModel-class-tp18797009p18797009.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Problem on external LoadableDetachableModel class

Posted by alex2008 <al...@yahoo.it>.
Thanks a lot Martin, your help was precious. =)


Martijn Dashorst wrote:
> 
> Odd, I thought it would contain instructions on how to inject
> non-component classes using:
> 
> Add this to the constructor of your non-component class (i.e. your model):
> 
> InjectorHolder.getInjector().inject(this);
> 
> See also [1]
> 
> Martijn
> 
> [1]
> http://markmail.org/message/u7lgvd2azwpl3m4a#query:+page:1+mid:xzzx2cz6si36x7bz+state:results
> 
> On Sun, Aug 3, 2008 at 3:10 PM, alex2008 <al...@yahoo.it> wrote:
>>
>> Thanks for the link.
>>
>> I read the article but i don't understand how i can resolve the problem.
>> --
>> View this message in context:
>> http://www.nabble.com/Problem-on-external-LoadableDetachableModel-class-tp18797009p18798487.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 
> 
> -- 
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.3.4 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-on-external-LoadableDetachableModel-class-tp18797009p18799466.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Problem on external LoadableDetachableModel class

Posted by Martijn Dashorst <ma...@gmail.com>.
Odd, I thought it would contain instructions on how to inject
non-component classes using:

Add this to the constructor of your non-component class (i.e. your model):

InjectorHolder.getInjector().inject(this);

See also [1]

Martijn

[1] http://markmail.org/message/u7lgvd2azwpl3m4a#query:+page:1+mid:xzzx2cz6si36x7bz+state:results

On Sun, Aug 3, 2008 at 3:10 PM, alex2008 <al...@yahoo.it> wrote:
>
> Thanks for the link.
>
> I read the article but i don't understand how i can resolve the problem.
> --
> View this message in context: http://www.nabble.com/Problem-on-external-LoadableDetachableModel-class-tp18797009p18798487.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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


Re: Problem on external LoadableDetachableModel class

Posted by alex2008 <al...@yahoo.it>.
Thanks for the link.

I read the article but i don't understand how i can resolve the problem.
-- 
View this message in context: http://www.nabble.com/Problem-on-external-LoadableDetachableModel-class-tp18797009p18798487.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Problem on external LoadableDetachableModel class

Posted by Martijn Dashorst <ma...@gmail.com>.
http://cwiki.apache.org/WICKET/spring.html#Spring-Using@SpringBeanbeyondWicket

On Sun, Aug 3, 2008 at 11:07 AM, alex2008 <al...@yahoo.it> wrote:
>
> ....
>  @SpringBean
>    private ProductManager productManager;
>    //@Autowired
>    public void setProductManager(ProductManager productManager) {
>        this.productManager = productManager;
>    }
> .....
>  LoadableDetachableModel personListModel = new LoadableDetachableModel() {
>            @Override
>            protected Object load() {
>                return productManager.getProducts();
>            }
>        };
> add(new ListView("products", personListModel) {
> ........
>        });
> It's ok.
>
>
> While if a use an external class:
> package wicketapp.util;
>
> import org.apache.wicket.model.LoadableDetachableModel;
> import org.apache.wicket.spring.injection.annot.SpringBean;
> import springapp.service.ProductManager;
>
> public class ProductModel extends LoadableDetachableModel {
>    @SpringBean
>    private ProductManager productManager;
>    //@Autowired
>    public void setProductManager(ProductManager productManager) {
>        this.productManager = productManager;
>    }
>
>    protected Object load() {
>        return productManager.getProducts();
>    }
> }
>
> ..........
>  ProductModel personListModel = new ProductModel();
>
>        add(new ListView("products", personListModel) {
>        .......
>        });
>
> It's wrong.
>
> Which is the problem?
> --
> View this message in context: http://www.nabble.com/Problem-on-external-LoadableDetachableModel-class-tp18797009p18797009.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

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