6 Replies Latest reply on Jun 11, 2008 4:42 PM by smscentral

    Bindable for boolean values

    smscentral
      Hi,

      i have a class with the property deployed as boolean
      [Bindable]
      public var deployed:Boolean;

      i change this value according to my httpservice result in afunction

      public function isDeployedResult(event:ResultEvent):void{
      var deployedResult:String = event.result.toString();
      if((deployedResult.localeCompare("true")) == 1)
      deployed = true;
      else if((deployedResult.localeCompare("false")) == 1)
      deployed = false;

      Alert.show("in deployment service== "+deployed);//this shows the correct value

      }

      but outside this function the value of deployed is always false;

      thanks
      chandana








        • 1. Re: Bindable for boolean values
          dietmar.paulus Level 1
          Hey

          First off all, this has nothting to do with the Bindable metadata-tag.

          If you trace or alert your boolean value, befor your isDeployedResult gets called, you boolean is false because, by default a boolean is false, if you never initialize it.

          I think that you try to trace or alert your boolean befor your isDeployedResult gets called.

          cheers

          dietmar
          • 2. Re: Bindable for boolean values
            smscentral Level 1
            Thanks for ur reply..
            i think u r right..
            one of the function using the bindable variable is being called even before the http result is processed..
            so how do i check if processing the result is completed or not so that i can call the next function with correct bindable values..

            chandana
            • 3. Re: Bindable for boolean values
              laurent_pinson
              When HTTPService gets a result, it dispatches an event

              quote:


              Event: result
              Description:Dispatched when an HTTPService call returns successfully.
              • 4. Re: Bindable for boolean values
                Where's the fault event handler to catch network/connection errors?

                Do you have a test case where the server returns false? How is that working?
                • 5. Re: Bindable for boolean values
                  atta707 Level 2
                  > Where's the fault event handler to catch network/connection errors?

                  look up for fault event in the HTTPService class.

                  ATTA
                  • 6. Re: Bindable for boolean values
                    smscentral Level 1
                    Thanks everybody

                    I solved the problem.

                    i have a component with creationComplete calling following method : checkDeployed()

                    public function checkDeployed():void{
                    this.clsname = (this.parentDocument as QueuesComponent).classname;
                    deploymentService = new MittoDeploymentService(clsname,queue.id);
                    deploymentService.isDeployed();
                    this.showButtons();

                    }


                    public function showButtons():void{

                    this.deployed = deploymentService.deployed;
                    if(this.deployed)
                    {
                    this.redeployqueue.visible=true;
                    this.updatequeue.visible=false;
                    this.deployqueue.visible=false;
                    this.undeploy.visible=true;
                    }
                    else
                    {
                    this.redeployqueue.visible=false;
                    this.updatequeue.visible=true;
                    this.deployqueue.visible=true;
                    this.undeploy.visible=false;
                    }
                    }


                    and the deployment service has the isDeployed method like this

                    public function isDeployed():void{
                    mittohttpRequest = new MittoBackendRequest("deploymentservice");
                    var action:String = "isdeployed";
                    mittohttpRequest.setRequest({action:action,classname:this.classname,checkdeploy:this.enti tyid});
                    mittohttpRequest.addEventListener(ResultEvent.RESULT,isDeployedResult);
                    mittohttpRequest.send();
                    }

                    public function isDeployedResult(event:ResultEvent):void{
                    var deployedResult:String = event.result.toString();
                    if((deployedResult.localeCompare("true")) == 1)
                    deployed = true;
                    else if((deployedResult.localeCompare("false")) == 1)
                    deployed = false;
                    }

                    the boolean deployed in [bindable]

                    here..show buttons is being called even before the result was obtained from the httpservice..and so the value is always false (default value of boolean) ..

                    so i changed the calling of methods like this :

                    initialize = "checkDeployed()" ,creationComplete = "showButtons()"
                    and now the boolean deployed is correct with binded value in my component..

                    hope the explanation is clear..

                    thanku all
                    chandana