DWR中提供XML的传递方法

自己用dom4j,所以用dom4j做例子;

java server:

method(){

return Document 类型;

}

没有dom4j的例子,借用xom的例子:

Element div = new Element("div");
Document doc = new Document(div);

div.addAttribute(new Attribute("id", "parentXOM"));
div.appendChild("This is text from XOMDemo. ");

Element button = new Element("input");
button.addAttribute(new Attribute("id", "buttonXOM"));
button.addAttribute(new Attribute("type", "button"));
button.addAttribute(new Attribute("value", text));
button.addAttribute(new Attribute("onclick", "alert('Events are enabled')"));

div.appendChild(button);

return doc;


看懂了吧,都是html标签.

javascript cliend:

验证是否有dom4j的支持(有没有相关的api)

DOM4J.getDocument("textDOM4J", function(data) {
DWRUtil.setValue("replyDOM4J", data);
DOM4J.debugDocument($("replyDOM4J"), function(data) {
if (data < 30 || data > 40) {
failure("DOM4J reply fail: " + data);
}
else {
success();
}
});
});
调用方法:

function getDOM4JDocument()
{
var text = DWRUtil.getValue("textDOM4J");
DOM4J.getDocument(handleGetDOM4JDocument, text);
}
function handleGetDOM4JDocument(data)
{
DWRUtil.setValue("replyDOM4J", data);
}

好了.呵呵
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值