/method"
event="onClick">
if(boxStore.isItem(lastBoxSelected)){
boxStore.setValue(lastBoxSelected,"name","新盒子");
}
2.5.4.4 将树的操作记录到后台数据库
dojoType="
dojo.data.ItemFileWriteStore" jsId="boxStore"
url="/
tree/box.json">
<script type="
dojo/connect" event="onNew" args="newItem">
var itemId = this.getValue(newItem,"id");
var itemName = this.getValue(newItem,"name");
dojo.xhrPost({
url:"agCreateNewBox?OpenAgent",
content:{id:itemId,name:itemName},
timeout:10000,
error:function(){alert("对不起,出错啦!");},
load:function(){alert("数据保存成功!");console.debug("数据保存成功!");}
});
dojo/connect” event=”onDelete” args=”delItem”>
2.5.4.5 树的拖放
要使树具有拖放功能,仅仅需要设置dndController属性(dijit._
tree.dndSource已废弃):
要限制拖放的行为,仅仅需要实现checkAcceptance或checkItemAcceptance处理函数即可:
以上已经实现了树的拖放功能了!
但是,如果要将拖放的结果保存起来,也就是说要改变树的模型并将模型数据保存,那么应该编写onDndDrop的处理函数(通过增加jsId获得dndController会出现this.avaria is null 错误,所以下面通过小部件初始化时将dndController传递给变量controller):
在boxDrop中与checkAcceptance一样可以得到target与source,另外,onDndDrop中的source与nodes有些相似source.selection[something]=nodes[somethin]
结合ItemFileWriteStore 可以实现对模型数据的保存
3 在Xpage中如何查找控件
3.1 理解document.getElementById
得到node,创建node可以用document.createElement
这样访问或设置节点的所有属性
node.innerHTML = “”
node.value=””
var id = node.id
var style = node.style
3.2 理解
dojo.byId
得到node,也可以通过dijit.byId().domNode得到节点
dojo.byId(“myid”).value
dojo.byid(“myid”).id
dojo.attr(node,attribute) 如读取
dojo.attr(node,”id”)
dojo.attr(node,attribute,value) 如设置
dojo.attr(node,”id”,”myid”)
dojo.hasAttr(node,attribute) 如判断
dojo.hasAttr(node,”id”)
dojo.connect(node,”onclick”,handler)
dojo.removeClass(node,”myclass”)
3.3 理解dijit.byId
得到
dojo控件对象,也可以通过dijit.byNode(
dojo.byId())得到对象
不同的控件的getValue()返回值类型不一样
在xpage中对于
标签可能使用期dijit.byId(“myid”),对于标签是不可以的
dijit.byId().getValue()
dijit.byId().setValue()
3.4 理解XSP.getElementById
这是XSPClientDojo 库中定义的,XSP全局变量相当于document对象,为客户端访问xpage控件提供方法
XSP.getElementById(“#{id:myid}”)使用JSF表达式查询控件
var xid = XSP.getElementById(“#{id:myid}”)
xid.value = “myvalue”
xid.name = “myname”
xid.disabled = false
3.5 理解getComponent
javascript服务器端访问控件
getComponet(“myid”).getValue();
getComponet(“myid”).getSubmittedValue();
getComponent(“myid”).setValue();
getComponent(“myid”).setSubmittedValue();
4 Xpage VS 表单
5 使用oneui主题
6 参考
6.1 JSON与String转换
dojo.fromJson(string) 返回json对象
dojo.toJson(object) 返回string对象
eval(‘(‘+string+’)’) 返回json对象
6.2 XPage中调试代码
window.alert 函数不可用于服务器脚本。
使用以下函数写入服务器上的 console.log(例如 C:\Notes\Data\IBM_TECHNICAL_SUPPORT\console.log):
print(string) 写入一个字符串。
_dump(object) 写入表示对象的字符串。