Initially autowired object has value it becomes null after paging using JSF 2 2 and spring 4 01

+1 vote


i'm trying to create basic crud operations using JSF 2.2,Spring 4.01 and Hibernate.


From register.xhtml,if I click register button,it should save firstname(as of now) in the db.


I have
1. registration page(register.xhtml)


2.RegistrationAction(Controller)

3.RegistrationEntity(Entity class which has only one field,firstName, as of now)

4.LoginRegistrationServiceImpl(service class)--I have interface (LoginRegistrationService)

In the controller class(RegistrationAction),when deploying,im getting the service class object,after I clicked the register button,it becomes null.

Below is my code:

RegistrationAction:

@ManagedBean(name="register")
@Controller

public class RegistrationAction implements Serializable{
  

     private RegistrationEntity regEntity=new RegistrationEntity();

    private LoginRegistrationService  lrInterfcae;

    public LoginRegistrationService getLrInterfcae() {
        return lrInterfcae;
    }

  
      @Autowired
 
    public void setLrInterfcae(LoginRegistrationService lrInterfcae) {           
        this.lrInterfcae = lrInterfcae;
        System.out.println("Interface Obj--"+lrInterfcae);
    }     
  

 
 
    public String registerUser(){
    
        System.out.println("Interface Obj--"+lrInterfcae);
     
        return "/login";
      
    }
  
    public RegistrationEntity getRegEntity() {
        return regEntity;
    }
  
    public void setRegEntity(RegistrationEntity regEntity) {   
        this.regEntity = regEntity;
    }


  
  
}

----------------------------------------------


SERVICE CLASS-LOGINREGISTRATIONSERIMPL


@Service


public class LoginRegistrationSerImpl implements LoginRegistrationService{
    }
  
  
-------------------------------------------------------------

SPRING-CONFIG.xml

<beans ....>


<context:component-scan base-package = "Controllers,Serviceimplementations,DAOImplementations" />
<!--<bean id="registerController" class="Controllers.RegistrationAction"/>-->
</beans>

-------------------------------------------------------------------

OUTPUT:

After deploymenent:


05-Jul-2019 02:52:58.387 INFO [http-nio-8084-exec-3] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
05-Jul-2019 02:52:58.564 INFO [http-nio-8084-exec-3] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization completed in 615 ms
05-Jul-2019 02:52:58.709 INFO [http-nio-8084-exec-3] com.sun.faces.config.ConfigureListener.contextInitialized Initializing Mojarra 2.2.7 ( 20140610-1547 https://svn.java.net/svn/mojarra~svn/tags/2.2.7@13362) for context '/matrimony'
05-Jul-2019 02:52:58.993 INFO [http-nio-8084-exec-3] com.sun.faces.spi.InjectionProviderFactory.createInstance JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans methods marked with these annotations will have said annotations processed.
05-Jul-2019 02:53:00.211 INFO [http-nio-8084-exec-3] org.springframework.web.servlet.FrameworkServlet.initServletBean FrameworkServlet 'dispatcher': initialization started
05-Jul-2019 02:53:00.222 INFO [http-nio-8084-exec-3] org.springframework.context.support.AbstractApplicationContext.prepareRefresh Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Fri Jul 05 02:53:00 IST 2019]; parent: Root WebApplicationContext
05-Jul-2019 02:53:00.224 INFO [http-nio-8084-exec-3] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions Loading XML bean definitions from ServletContext resource [/WEB-INF/springConf/newSpringXMLConfig.xml]
Interface Obj--Serviceimplementations.LoginRegistrationSerImpl@38635264
05-Jul-2019 02:53:01.239 INFO [http-nio-8084-exec-3] org.springframework.web.servlet.FrameworkServlet.initServletBean FrameworkServlet 'dispatcher': initialization completed in 1028 ms
05-Jul-2019 02:53:01.242 INFO [http-nio-8084-exec-3] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/matrimony] is completed


AFTER CLICKING THE REGISTER BUTTON:(IT BECOMES NULL)


05-Jul-2019 02:53:01.242 INFO [http-nio-8084-exec-3] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/matrimony] is completed

Interface Obj--null

-------------------------------------

NOTE:I have tried all scopes. and also tried by keeping @ManagedBean and @Controller (classes) separately.

Register.xhtml:

inputText:firstname

commandbutton:Register,in action attribute I called registerUser method of RegistrationAction class.

Jul 5, 2019 in Java by swats
1,652 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java

0 votes
1 answer

how to read csv file form sftp connection and store into string object in java code and convert into json.....post it using rest api

Hey, @Pooja, Before starting with anything you should ...READ MORE

answered May 13, 2020 in Java by Roshni
• 10,480 points
3,829 views
0 votes
2 answers

How can I create File and write data in it using Java?

import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class WriteFiles{ ...READ MORE

answered Jul 26, 2018 in Java by samarth295
• 2,220 points
2,924 views
0 votes
2 answers

How do I get the current date and time using Java?

If you require a time stamp in ...READ MORE

answered Aug 23, 2019 in Java by Sirajul
• 59,230 points
2,934 views
0 votes
2 answers

How do I read and convert an InputStream object to string type?

You can also use Java Standard Library ...READ MORE

answered Jul 17, 2018 in Java by Sushmita
• 6,920 points
17,230 views
0 votes
2 answers

What is the use of toString method in Java and how can I use it ?

Whenever you require to explore the constructor ...READ MORE

answered Aug 23, 2018 in Java by Daisy
• 8,140 points
4,103 views
+1 vote
3 answers

Copy Java Array and make a duplicate of it

int[] a = {1,2,3,4,5}; int[] b = Arrays.copyOf(a, ...READ MORE

answered Aug 30, 2018 in Java by Sushmita
• 6,920 points
1,700 views
0 votes
1 answer
0 votes
1 answer

@Component vs @Repository vs @Service in Spring Framework

As you might be knowing, all these ...READ MORE

answered May 29, 2018 in Java by geek.erkami
• 2,680 points
3,651 views
0 votes
1 answer

"No mapping found for HTTP request with URI[....] in DispatherServlet"

Your standard Spring MVC application will serve ...READ MORE

answered Jun 6, 2018 in Java by prasad
• 160 points
21,687 views
0 votes
1 answer

Autowired field pointing NULL in Spring

The field annotated @Autowired is null because ...READ MORE

answered Jun 6, 2018 in Java by Avi
• 160 points

edited Mar 4, 2022 by Sarfaraz 14,468 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP