小新 的 BLOG
            
            -=毕业后新的开始-第一阶段=-

flex页面间传参数及与parent window的交互(2)

   企业信息化2005-4-1 10:51
2、在一个与application绑定的文档中传参数来操作parent页面,最好的方法莫过于把整个application传过去
下面是与application绑定as文件的一段代码
var dept = mx.managers.PopUpManager.createPopUp(this, addDept,true,{x:225, y:30,parentHS:this.parentApplication.hs_tree}, true);
通过this.parentApplication.hs_tree把application页面的httpservice传到弹出窗口中
在弹窗口声明:var parentHS;
用parentHS.send()直接调用即可当然也可进行其他的操作!!
如果application页面一个树的dataProvider由httpservice提供的话就可以通过send()函数来更新树!!

3、使用getURL函数实现页面重定向、传参数以及乱码的解决
getURL的语法:getURL(url [, window [, "variables"]])url是转向的页面路径跟jsp相似我们可以通过url里边传参数在转到的页面里,window是字符串有_self(当前页面) _blank 打开一个新的页面_parent、_top等
例子
在页面index.mxml中
var name1:String = "bluelover";
this.getURL("nextPage.mxml?name1="+name1+"","_self");跟jsp里的window.open 和<a href=url>中的url很像吧!
老样子在nextPage.mxml页面中通过var name1来取值如想象中的参数传过去了正确显示。但是我们要传的是汉字改为"小新",还是跟jsp一样乱码。
在flex中有个函数escape() 把字符串转化为URL-encoded format再用unescape()转化回来作用跟encoding差不多。按照思路在index.mxml页面中调用escape()在nextPage中调用unescape()不过还是一堆乱码。反复试了几次,在index.mxml页面调用两次escape()在nextPage.mxml调用一次unescape()就能正确转换!!
页面nextPage.mxml显示"小新"
标签集:TAGS:
回复Comments()点击Count()

回复Comments

{commenttime}{commentauthor}

{CommentUrl}
{commentcontent}
  用户登录
用户名
密 码
选 项:
 
  我的日历
  分类日志
  访问计数
  获取 RSS
bluelover 最新的 20 条日志
  最新评论
  友情链接
  联系我
                  GMail:bluelover@gmail.com
MSN:xini_huang@hotmail.com
QQ:85364603
Modified by blueloverPowered by 5DBlog.com