1 Reply Latest reply on Jul 20, 2006 4:17 PM by gavin.king

    Injection problem on form submit.

    mjrpain

      I have a page that displays several select boxes whose content was acquired from an oracle datasource that was injected using @Resource(mappedName = "java:/myDatasource").

      The submit button calls a different action class that is to instantiate the correct DAO, get the data and forward to the appropriate .xhtml. The submit button fragment is shown here.

      <h:commandButton type="submit" action="#{reportList.submit}"/>
      


      The method being called is simulated here.
      @Name("reportList")
      public class ReportListAction implements ReportListLocal {
      
       @Resource(mappedName = "java:/myDatasource")
       private DataSource ds;
      
       private Connection conn = null;
      
       public String submit() {
       // using ds here results in a nullpointer. Why?
       conn = ds.getConnection();
       }
      
       // other setters to receive the form element values
      
      }
      


      My problem though is that the datasource that was supposed to be injected into ReportListAction is null when I try to use it in the submit() method. The datasource is declared in the exact same manner as the other POJO that gets the data for the select boxes on the first page. What am I missing?

      BTW...I appreciate your help in telling me about the @Resource annotation in an earlier post.