Flash Builder更新查询问题 - 通道已断开通道在收到确认之前已断开连接

时间:2010-04-01 20:43:14

标签: actionscript-3 flash flex flex4 mxml

我正在尝试构建我的第一个CRUD应用程序,并且无法使更新查询正常工作。这是MXML和AS。

<?xml version="1.0" encoding="utf-8"?>

<fx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import mx.events.DataGridEvent;
        import mx.events.FlexEvent;
        import mx.rpc.events.ResultEvent;

        protected function init(event:FlexEvent):void
        {
            // TODO Auto-generated method stub
            //login.addEventListener(MouseEvent.CLICK, clickMe);
        }

        protected function doLogin(event:MouseEvent):void
        {
            trace('doLogin');
            //Alert.show("doLogin");
            loginResult.token = customUserClass.login(username_txt.text, password_txt.text);

            //sayHelloResult.token = user.sayHello('Jeff');
            //sayHelloResult.addEventListener(ResultEvent.RESULT, fromCallingHello);
        }

        protected function loginResultEvent(event:ResultEvent):void {
            //Alert.show(event.result.toString(), 'loginResult');
            trace (event.result.toString());
            if (event.result == true) {
                currentState = 'LoggedIn';
            }
        }

        //protected function fromCallingHello(event:ResultEvent):void {
        //  Alert.show(event.result.toString(), 'fromCallingHello');
        //  trace (event.result.toString());
        //}


        protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
        {
            getAllUsersResult.token = usersService.getAllUsers();
            //usersService.getAllUsers();
        }


        protected function dataGrid_itemEditEndHandler(event:DataGridEvent):void
        {
            // TODO Auto-generated method stub
            //var user:Users = new Users();
            //userServiceValueObject[event.dataField]=(dataGrid.itemEditorInstance as mx.controls.TextInput).text;
            //usersService.updateUsers(userServiceValueObject);
        }       

        protected function delete_btn_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub
            usersService.deleteUsers(dataGrid.selectedItem.id);
        }


        protected function update_btn_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub
            //var users:Users = new Users();
            userServiceValueObject.id = parseInt(idTextInput.text);
            userServiceValueObject.firstname = firstnameTextInput.text;
            userServiceValueObject.lastname = lastnameTextInput.text;
            userServiceValueObject.email = emailTextInput.text;
            userServiceValueObject.username = usernameTextInput.text;
            userServiceValueObject.password = passwordTextInput.text;
            userServiceValueObject.joindate = joindateDateField.selectedDate;
            updateUsersResult.token = usersService.updateUsers(userServiceValueObject);
            //usersService.updateUsers(userServiceValueObject);
            usersService.getAllUsers();
            //usersService.updateUsers(userServiceValueObject);
        }

        //protected function updateUsers(item:Users):void
        //{
        //  updateUsersResult.token = usersService.updateUsers(item);
        //}

        protected function dataGrid_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub
            idTextInput.text = dataGrid.selectedItem.id;
            firstnameTextInput.text = dataGrid.selectedItem.firstname;
            lastnameTextInput.text = dataGrid.selectedItem.lastname;
            emailTextInput.text = dataGrid.selectedItem.email;
            usernameTextInput.text = dataGrid.selectedItem.username;
            joindateDateField.text = dataGrid.selectedItem.joindate;
        }


        protected function revert_btn_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub
            usersService.getDataManager(usersService.DATA_MANAGER_USERS).revertChanges();
        }


        protected function save_btn_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub
            usersService.commit();
        }


        protected function create_btn_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub
            //datatestService.createDatatest(datatest);
            //datatestService.getAllDatatest();
            //usersService.createUsers(userServiceValueObject);
            //usersService.getAllUsers();
            //var users:Users = new Users();
            //users.id = parseInt(idTextInput.text);
            userServiceValueObject.firstname = firstnameTextInput.text;
            userServiceValueObject.lastname = lastnameTextInput.text;
            userServiceValueObject.email = emailTextInput.text;
            userServiceValueObject.username = usernameTextInput.text;
            userServiceValueObject.password = passwordTextInput.text;
            userServiceValueObject.joindate = joindateDateField.selectedDate;
            //createUsersResult.token = 
            usersService.createUsers(userServiceValueObject);
            usersService.getAllUsers();
            //dataGrid.
        }


    ]]>
</fx:Script>
<s:states>
    <s:State name="Login"/>
    <s:State name="LoggedIn"/>
</s:states>

<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    <customuserclass:CustomUserClass id="customUserClass" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true" />
    <s:CallResponder id="sayHelloResult"/>
    <s:CallResponder id="loginResult" result="loginResultEvent(event)"/>


    <usersservice:UsersService id="usersService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
    <valueObjects:Users id="userServiceValueObject"/>
    <s:CallResponder id="getAllUsersResult"/>
    <s:CallResponder id="createUsersResult"/>
    <s:CallResponder id="deleteUsersResult"/>
    <s:CallResponder id="updateUsersResult"/>       

</fx:Declarations>

<s:Panel width="250" height="140" verticalCenter="0" horizontalCenter="0" title="Login" includeIn="Login">
    <s:layout>
        <s:BasicLayout/>
    </s:layout>
    <s:TextInput x="87" y="10" id="username_txt" width="151" text="jguthrie"/>
    <s:TextInput x="87" y="40" id="password_txt" width="151" text="test"/>
    <s:Label x="10" y="10" text="Username:" fontSize="14"/>
    <s:Label x="10" y="44" text="Password:" fontSize="14"/>
    <s:CheckBox x="10" y="68" label="Remember Me"/>
    <s:Button x="168" y="69" label="Login" id="login" click="doLogin(event)"/>
</s:Panel>
<s:Label includeIn="LoggedIn" x="836" y="10" text="Manage Users:" fontSize="20"/>
<mx:DataGrid includeIn="LoggedIn" x="289" y="31" id="dataGrid" click="dataGrid_clickHandler(event)" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllUsersResult.lastResult}" editable="true" itemEditEnd="dataGrid_itemEditEndHandler(event)">
    <mx:columns>
        <mx:DataGridColumn headerText="id" dataField="id"/>
        <mx:DataGridColumn headerText="username" dataField="username"/>
        <mx:DataGridColumn headerText="firstname" dataField="firstname"/>
        <mx:DataGridColumn headerText="lastname" dataField="lastname"/>
        <mx:DataGridColumn headerText="email" dataField="email"/>
        <mx:DataGridColumn headerText="joindate" dataField="joindate"/>
    </mx:columns>
</mx:DataGrid>
<mx:Form includeIn="LoggedIn" x="289" y="258">
    <mx:FormItem label="Id">
        <s:TextInput id="idTextInput" text="{userServiceValueObject.id}"/>
    </mx:FormItem>
    <mx:FormItem label="Firstname">
        <s:TextInput id="firstnameTextInput" text="{userServiceValueObject.firstname}"/>
    </mx:FormItem>
    <mx:FormItem label="Lastname">
        <s:TextInput id="lastnameTextInput" text="{userServiceValueObject.lastname}"/>
    </mx:FormItem>
    <mx:FormItem label="Email">
        <s:TextInput id="emailTextInput" text="{userServiceValueObject.email}"/>
    </mx:FormItem>
    <mx:FormItem label="Username">
        <s:TextInput id="usernameTextInput" text="{userServiceValueObject.username}"/>
    </mx:FormItem>
    <mx:FormItem label="Password">
        <s:TextInput id="passwordTextInput" text="{userServiceValueObject.password}"/>
    </mx:FormItem>
    <mx:FormItem label="Joindate">
        <mx:DateField id="joindateDateField" selectedDate="{userServiceValueObject.joindate}"/>
    </mx:FormItem>
</mx:Form>
<mx:Form includeIn="LoggedIn" x="536" y="258">
    <mx:FormItem label="CreateUsers">
        <s:TextInput id="createUsersTextInput" text="{createUsersResult.lastResult as int}"/>
    </mx:FormItem>
</mx:Form>
<s:HGroup includeIn="LoggedIn" x="289" y="221" width="602" height="33">
    <s:Button includeIn="LoggedIn" label="Create" id="create_btn" click="create_btn_clickHandler(event)"/>
    <s:Button includeIn="LoggedIn" label="Update" id="update_btn" click="update_btn_clickHandler(event)"/>
    <s:Button includeIn="LoggedIn" label="Revert Update" id="revert_btn" click="revert_btn_clickHandler(event)"/>
    <s:Button includeIn="LoggedIn" label="Save Update" id="save_btn" click="save_btn_clickHandler(event)"/>
    <s:Button includeIn="LoggedIn" label="Delete" id="delete_btn" click="delete_btn_clickHandler(event)"/>
</s:HGroup>

1 个答案:

答案 0 :(得分:0)

我遇到了这个错误,我的搜索引导我发了一条说明,当PHP发生错误时,该消息会回来。快速查看我的PHP日志的结尾显示了我输入错误的变量,之后是一个快速修复。