Results 1 to 4 of 4

Thread: Populate h:selectOneMenu on page load with spring

  1. #1

    Default Populate h:selectOneMenu on page load with spring

    Hi,

    I am using Spring + JPA + JSF + RichFaces integration with oracle as database server.

    In my jsf page i have the following code:

    Code:
    <h:selectOneMenu id="serviceId" value="#callListBean.callListVO.selectedPatient}">        
    <f:selectItems value="#{callListBean.callListVO.patientList}"  />
    </h:selectOneMenu>
    I have to populate it when this page gets loaded. Following is my Java Code:

    Code:
    class SomeClass()
    {
      // spring will inject this service
      private SomeSpringInjectedService  service;
      private SomePOJO  pojo;
      private List  patientList
    
     // constructor
      public SomeClass()
    {
       patientList = service.getResult();
    
    }
     public String populate()
    {
       
    
    }
    
    
    }
    but when the above code executed, it gives the NullPointerException. I know the reason that when constructor executes, 'service' is null as spring will inject this after the constructor's execution.

    Please help me how to populate my dropdown menu on page load.

    thanks
    Muhammad Ijaz (Pomy)

  2. #2

    Default

    I also tried the following in the constructor

    service = (SomeSpringInjectedService)ApplicationContext.getB ean("service ")

    but it is also giving null pointer exception. ApplicationContext is a ApplicationContext Context Aware class
    Muhammad Ijaz (Pomy)

  3. #3

    Default

    Quote Originally Posted by ranaijazahmad View Post
    I also tried the following in the constructor

    service = (SomeSpringInjectedService)ApplicationContext.getB ean("service ")

    but it is also giving null pointer exception. ApplicationContext is a ApplicationContext Context Aware class
    This is really strange cause I have exactly the same situation and my code works fine.

  4. #4

    Default

    Thanks Josué,

    It is resolved. Actually I didn't registered the ApplicationContext Context Aware class into ApplicationContext.xml
    Muhammad Ijaz (Pomy)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •