自己用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);
}
好了.呵呵
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);
}
好了.呵呵