Wicket-Spring bean with REQUEST SCOPE does not get instantiated on ajax request

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Wicket-Spring bean with REQUEST SCOPE does not get instantiated on ajax request

pramonotunggul
This post has NOT been accepted by the mailing list yet.
Hi All,

As previously discussed in this forum, there is integration between spring and wicket, which is called wicket-spring.

As spring support REQUEST, SESSION, etc scoped bean. I noticed that this integration is not perfect in wicket.

Here is the case

@Service
@Scope("request")
public class DBConnection{
   public DBConnection(){}
   public void connect(){
      // Connect here
      System.out.println("Connect");
   }
   @PreDestroy
   public void disconnect(){
      System.out.println("Disconnect");
      // Disconnect
   }

}



Another java file
public class RegistrationForm extends Panel{
@SpringBean
private DBConnection connection;
   public RegistrationForm(String id){
      super(id);
      add(new AjaxLink("link"){
         @Override
         public void onClick(AjaxRequestTarget target){
               // connection is accessible and instantiated from here
               System.out.println("Clicked");
         }
      });
   }
}

As you see the code above,
The result will be

Connect
Disconnect
// Wait user input, when someone click the ajax link
Clicked

The conclusion is request scoped bean does not get called on ajax request.

Could any of you explain how to make Request scoped bean to be able to be called on ajax request, since this problem will prevent spring IOC to perfectly manage Database connection session.

Any advice will be appreciated.