Adobe Flash Builder 4 +myeclipse开发中的问题
用的Adobe Flash Builder 4的BLazeDs连接数据服务,以可以通信问题是:
updateyh.mxml里:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:services="services.*">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import valueObjects.YongHu;
protected function update_clickHandler(event:MouseEvent):void
{
var yhn:YongHu=new YongHu();
yhn.username=username.text;
yhn.pwd=npwd.text;
updateusersResult.token = operUser.updateusers(yhn);
Alert.show(updateusersResult.lastResult);
if(updateusersResult.lastResult == true){
Alert.show("修改成功!");
}else{
Alert.show("修改失败!");
} }
]]>
</fx:Script>
<fx:Declarations>
<services:OperUser id="operUser" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
<s:CallResponder id="selectbyusenameResult"/>
<s:CallResponder id="selectbypwdResult"/>
<s:CallResponder id="updateusersResult"/>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Label y="92" text="用户名:" horizontalCenter="-88"/>
<s:TextInput y="83" horizontalCenter="3" id="username"/>
<s:Label y="153" text="旧密码:" horizontalCenter="-88"/>
<s:Label y="218" text="新密码:" horizontalCenter="-88"/>
<s:TextInput y="143" horizontalCenter="3" id="pwd"/>
<s:TextInput y="208" horizontalCenter="3" id="npwd"/>
<s:Button y="283" label="修 改" id="update" click="update_clickHandler(event)" horizontalCenter="-72"/>
<s:Label y="93" text="{selectbyusenameResult.lastResult}" id="a" horizontalCenter="119" color="#E53939"/>
<s:Label y="153" text="{selectbypwdResult.lastResult}" id="b" horizontalCenter="118" color="#E53939"/>
</s:WindowedApplication>
所得的值在第一次点击修改的时候是空,点击第2次才是java那边传过来的值,怎么回事???
java方法代码:
package com.zg.oper;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import com.zg.db.ConnectDB;
import com.zg.voo.YongHu;
public class OperUser {
private Connection conn;
private PreparedStatement pstmt;
private ResultSet rs;
//修改用户信息
public boolean updateusers(YongHu yh){
boolean flag=false;
conn=new ConnectDB().getConn();
try {
String sql="update zjcf_yonghu set Pwd=? where Username=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, yh.getPwd());
pstmt.setString(2, yh.getUsername());
//System.out.println(yh.getUsername());
//System.out.println(yh.getPwd());
int count=pstmt.executeUpdate();
if(count>0){
return true;
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
if( pstmt != null )
pstmt.close();
if( conn != null )
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return flag;
}
}