mardi 26 mai 2015

Spring @autowire doesnot work inside @component

I have a spring annotated class defined below

@component   
public class FormFilter extends DroplistFilterEditor{    

   @autowire   
   private PersonService personService;

   @Override
   protected List<Option> getOptions()
   {
      List<Option> options = new ArrayList<Option>();
      try {
         String fieldName = getColumn().getProperty();
         List<StudyListView> studyList = null;
         studyList=personService.findList();
         for(StudyListView study:studyList){
           options.add(new Option(study.getId(),study.getDesc()));
         }       
     } catch (Exception ex) {
       ex.printStackTrace();
     }
     return options;
   }
}

I am trying to call this class from jsp to display a dropdown list on page load. We are using jMesa for table rendering.

While the application is deploying the above class gets loaded but while it is called from jsp the personService object is null. The autowiring is not happening.

I am new to Spring MVC as well as jMesa. Any help appreciated. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire