Hi everybody.
First I would like to thanks you for the help you gave me.
But I've got another question for you.
I would like to know if it's possible to override the annotation @SpringBean
?
Why do I need to do that?
Let try a little simple example:
I want to print this
"Hello Internal"
and in another page (or ajax panel)
"Hello Commercial"
But I would like to use the same panel and not have to do a lots of "if
else" in my code. So here my panel code:
Panel.java
public class MyPanel extends CustomPanel{
private transient HelloService service;
public void initService(){
service =
ServiceFactory.get("helloService",getCommercialOrInternalState());
}
public MyPanel(String id){
initService();
IModel model = new LoadableDetachableModel(){
load(){
service.sayHello();
}
};
add(new Label("label",model));
}
My services:
public interface HelloService{
public String sayHello();
}
public HelloServiceInternalImpl implements HelloService{
public String sayHello(){
return "Hello Internal";
}
}
public HelloServiceCommercialImpl implements HelloService{
public String sayHello(){
return "Hello Commercial";
}
}
In my applicationContext.xml file
<bean id="helloServiceInternal" class="service.HelloServiceInternalImpl /">
<bean id="helloServiceCommercial" class="service.HelloServiceCommercialImpl
/">
Well, this way to do can work but sometime I don't know why i've some
NullpointerException then I'm asking myself if it's a good practice create
the service in the constructor.
And I think it's would be more elegant to write something like that:
@CustomSpringBean
private HelloService service;
If someone have an idea he would be awesome to share it.
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/How-to-override-annotation-SpringBean-tp4597030p4597030.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]