Question

In my Application using Flex-Blazeds-java...,in my Flex application side have two mxml file

  1. Main.mxml
  2. Login.mxml

In Main.mxml file have button called Login click this button one popup open that is called Login.mxml in this File i have authentication logic to connect java...sample code`

public var userService:UserService = new UserService();
[Bindable] public var userVO1:UserVO = new UserVO();
protected function loginUser(event:MouseEvent):void
{

var rpcAuthenticateUser:AsyncToken = userService.authenticateUser(userid_id.text, password_id.text);//Hear authenticateUser(-,-) is a java method it return UserVO object
rpcAuthenticateUser.addResponder(new mx.rpc.Responder(handler_success, handler_failure));

}
private function handler_failure(event:FaultEvent): void {
Alert.show("in handler_failure :" + event.message);

}


   private function handler_success(event:ResultEvent): void {
    userVO = event.result as UserVO;
     Alert.show("test "+userVO.loginId);
        }

Hear Login Working Perfectly according my Database logic and also if it is ResultEvent the Alert box show correct value (for ex:loginId is 'narasimham')...and everthing working perfectly no default in Login.mxml

Now The Problem Start...

I want to Use UserVO object in Main.mxml file so in that i'm using following code..

     public var loginUserVar:Login = new Login();
  protected function afterLoginUser(event:FlexEvent):void
   {
    Alert.show("LoginId ="+loginUserVar.userVO.loginId);        
   }

Actually my thinking this Alert box giving value narasimham but it is giving null value.

Why it is giving Null value?Is their any Scope specify to create variable?

Was it helpful?

Solution 2

Correct Ethrbunny i'm not store the value of userVO object so it is not available to Out side mxml file....

That's way in Flex(3.5) Application in Login.mxml file i'm adding following code...

Application.application.userVO = event.result as UserVO;
//Hear userVO is Object defined in Main.mxml file....

OTHER TIPS

In handler_success you need to set the value of userVO1 otherwise it won't be available otuside of your mxml file. You also need to to reference it in afterLoginUser as userVO1 instead of userVO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top