Does DI not occur before the session is setup? I t...
# fw1
s
Does DI not occur before the session is setup? I thought I had this working, but restarting my server is showing an error on trying to reference a service The service is available in before() but not in setupSession() apparently
Copy code
public void function setupSession() {
		// set up a default session
		variables.userService.defaultUserSession();

	}

	function before( struct rc = {} ) {
		
		// reset the application 
		if(structKeyExists(rc, 'resetApp')) {
			userService.logout();
		}
		
		// user session data
		rc["userSession"] = variables.userService.getUserSession();
				
	}
I am getting Original exception in onSessionStart The action main.default failed. Component [Application] has no accessible Member with name [USERSERVICE] (expression)
c
It's been a few years since I wrote any FW/1 code, but I think you need to access the framework directly and get the bean factory, and then request it from the beanfactory. Something like this maybe (may or may not work):
Copy code
public void function setupSession() {
  // Get the beanFactory
  var bf = variables.framework.getBeanFactory();
  var userService = bf.getBean( 'userService' );
  ...
}
👍 1