posts - 63,comments - 71,trackbacks - 0

想用msagent 实现即时通讯 但是用javascript操作msagent的时候必须不断刷新页面,这肯定是不能忍受的,想到了流行的ajax技术,用dwr实现定时刷新 ,
1。在页面里面加入
<script src='<%= request.getContextPath() %>/dwr/interface/ListWorkflowTaskAJAXProcess.js'></script>
<script src='<%= request.getContextPath() %>/dwr/engine.js'></script>
<script src='<%= request.getContextPath() %>/dwr/util.js'></script>
2。然后用
function InitList(){
  var frm = document.listWorkflowProgressForm;
  callAjax(frm.curStartRowNo.value,frm.sortAttribute.value,frm.sortOrder.value, retriveList);
    setTimeout("InitList()",<%=m_refreshInterval%>);
}
3。function callAjax(curStartRowNo, sortAttribute, sortOrder, retriveList){
  var frm = document.listWorkflowProgressForm;
  frm.curStartRowNo.value=curStartRowNo;
  frm.sortAttribute.value=sortAttribute;
  frm.sortOrder.value=sortOrder;
  ListWorkflowTaskAJAXProcess.getWorkflowTaskList(curStartRowNo, sortAttribute, sortOrder, frm.filterStepID.value, retriveList);//在javascript里面就可以调用java class了
}
4.msagent 参考代码
<script>

var chName;

var agent;

var Merlin;

chName = "Merlin";

agent = new ActiveXObject("Agent.Control.2");

agent.Connected = true; agent.Characters.Load(chName,chName+".acs");

Merlin = agent.Characters(chName); Merlin.MoveTo(200,200); Merlin.Show();

Merlin.Play("Announce");

Merlin.Speak("欢迎来到detrox的个人主页");

Merlin.Play("Explain");

Merlin.Speak("咳,这里收录了detrox和他朋友的文章。希望您能喜欢。");

Merlin.Play("Idle1_1");

Merlin.Play("Pleased");

Merlin.Speak("请进吧,我的客人");

Merlin.MoveTo(600,300);

Merlin.Play("Surprised");

Merlin.Speak("哦对了,大家最近小心非典。多多注意哦");

Merlin.Play("Idle1_2");

Merlin.Play("GestureUp");

Merlin.Speak("祝您在这里愉快");

Merlin.Play("Read");

Merlin.Hide();

</script>

posted on 2006-09-03 12:15 还没想好名 阅读(510) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: