1 Reply Latest reply on Feb 5, 2010 8:19 AM by ssilvert

    How to call function upon loading of JSF Context

      IN JSP i used to put things in bean's constructor which is in APPLCIATION scope,
      similarly
      i want to load a function upon deploy of application where i can put .

      i tried putting in listener but @ that time i am not getting faces config 's injection .

      so is there any way out ?

       

       

      here is my faces-config

      1. <?xml version='1.0' encoding='UTF-8'?> 
      2.  
      3. <!-- =========== FULL CONFIGURATION FILE ================================== --> 
      4.  
      5. <faces-config version="1.2"  
      6.     xmlns="http://java.sun.com/xml/ns/javaee"  
      7.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
      8.     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
      9.     <managed-bean> 
      10.         <managed-bean-name>bookBean</managed-bean-name> 
      11.         <managed-bean-class>DataBean</managed-bean-class
      12.         <managed-bean-scope>application</managed-bean-scope> 
      13.     </managed-bean> 
      14. </faces-config> 

      here is my bean
        • 1. Re: How to call function upon loading of JSF Context
          ssilvert

          In JSF 2.0 there is a system event that you can listen for during initialization.  So it's pretty straightforward.

           

          In JSF 1.2, the best way to do this might depend on what you are trying to accomplish.  But you can always do initialization with a ServletContextListener.  ServletContext.setAttribute() puts things in application scope.

           

          Stan