flex获得session
--------web.xml文件
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>
--------Java代码
public class GetSeesion {
/**
* 设置session
* */
public void setSession(String name,String value){
FlexContext.getFlexSession().setAttribute(name, value);
}
//获得session
public String getSession(String name){
String userid=(String) FlexContext.getFlexSession().getAttribute(name);
return userid;
}
}
----------在remoting-config.xml中加入
<!-- 用户信息保存到session中 -->
<destination id="sessionBiz">
<properties>
<source>com.ssfx.util.GetSeesion</source>
<scope>application</scope>
</properties>
</destination>
-------使用session
<mx:RemoteObject id="sBiz" destination="sessionBiz" showBusyCursor="true">
<mx:method name="setSession"/>
<mx:method name="getSession" result="sessionHandle(event)"/>
</mx:RemoteObject>
<script>
<![CDATA[
sBiz.setSession("userId",txtUserId.text);
sBiz.getSession("userId");
/* 获得后台session处理函数 */
private function sessionHandle(event:ResultEvent):void{
var userCode=String(event.result);
this.addPlanMess(userCode);
}
]]>
</script>
相关文档:
Glow:
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the Glow effect. -->
<!--
如何使用Flex Glow Effect
&n ......
在Flex应用中常常需要以一定的格式来显示时间,以下是一种做法。
首先创建一个DateFormatter 控件
<mx:DateFormatter id="df" formatString="YYYY-MM-DD JJ:NN:SS"/>
formatString="YYYY-MM-DD JJ:NN:SS"指定了时间的格式为2009-6-20 19:02:27,这里可以设置成自己需要的格式。
然后写个函数
......
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" creationComplete="initApp()">
<mx:Script>
<![CDATA[
public var pageRecordes:uint = 8;
public var totalPages:ui ......
分页组件:Page.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" >
<mx:Script>
<![CDATA[
&nbs ......