java后台flex前台例子
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
java后台flex前台例子
【篇一:java后台flex前台例子】
第一次写教程:写的不够详细,请原谅,评论,在线回答,谢谢
1 新建flex的项目工程叫jflogin
2 下一步
3 再下一步
4 部署
5 改server
6 改builder flex,再确定
7 右键项目,myeclipse addweb project
8 creatweb.xml一定不要勾上
9 部署添加项目到tomcat,并且打开tomcat服务
10 显示项目,右键项目,runas flex application(或者浏览器)是否操作成功
如上图就成功显示,如果出现404错误就安装自己实际情况重新配置上面5、6步骤就可以了
下面比较简单先,就不截图了
11 新建class login.java
package com.test.login;
public class login {
public boolean loginusern(stringusername,string userpwd){ if(username.equals(qing) (userpwd.equals(qing))){
returntrue;
}
else{
returnfalse;
}
}
}
12 在项目的webroot web-inf flex remoting-config.xml下添加如下
destinationid=userlogin
properties
source com.test.login.login /source
/properties
/destination
13 在jflogin.mxml中修改为
?xml version=1.0encoding=utf-8?
mx:application xmlns:mx=layout=absolute
creationcomplete=initapp();fontsize=16
mx:script
![cdata[
importmx.rpc.events.resultevent;
importmx.rpc.events.faultevent;
importmx.controls.alert;
publicfunction initapp():void{
btn.addeventlistener(mouseevent.click,shows);//监听btn按钮的触发事件
}
publicfunction shows(event:event):void{
var username:string=uname.text;
var userpwd:string=upass.text;
newr.addeventlistener(faultevent.fault,err);
newr.loginusern.addeventlistener(resultevent.result,secc); newr.loginusern(username,userpwd);
}
publicfunction err(event:faultevent):void{
alert.show(event.message.tostring());
}
publicfunction secc(event:resultevent):void{
var re:boolean = event.result;
if(re==true){
alert.show(哇晒,你太棒了,用户名和密码都正确,欢迎您进入!,正确);
}else{
alert.show(哇哈哈,你用户名密码都错误啊,我怎能给你进来啊!,错误);
}
}
]]
/mx:script
mx:button x=156.5 y=152 label=验证用户名与密码id=btn/
mx:label x=144 y=48 text=用户名:id=txt/
mx:remoteobject id=newr
destination=userloginshowbusycursor=true /
mx:textinput x=217 y=46id=uname/
mx:label x=144 y=96 text=密码:id=txt0/
mx:textinput x=217 y=94id=upass/
mx:stringvalidator source={uname} maxlength=20minlength=3 property=text toolongerror=名字不能超过{0}个字母tooshorterror=名字不能少于{0}位 /
mx:stringvalidator source={upass} maxlength=30minlength=3 property=text toolongerror=密码不能超过{0}个字母tooshorterror=密码不能少于{0}位 /
/mx:application
14 重新部署tomcat,重新启动tomcat
15 输入qing,qing时候,如果显示如下正确,就说成功
简单连接java后台,其他更复杂的后台也可以这样去实现了。