52,797
社区成员
发帖
与我相关
我的任务
分享
<form id="addform" action="addDefaultannounce.action" method="post">
<struts:textfield id="announce.CAtitle" name="announce.CAtitle" label="标题" required="true" maxlength="64" size="64" />
</p>
<struts:select id="announce.CAclass" name="announce.CAclass"
list="settingList" listKey="id" listValue="paramValue" label="类别" required="true"></struts:select>
<p>
<label for="editor1">
内 容:
</label>
<textarea cols="80" id="editor1" name="announce.CAcontent" rows="10"></textarea>
</p>
<p>
<center>
<div class="demo">
<input type="submit" value="发 布" style="font-size: 40px; color: #000000;" onclick="javascript:document.getElementById('announce.NAstates').value='3';" />
<input id="dzddraft" type="button" value="保存草稿" style="font-size: 40px; color: #000000;"/>
<input type="button" value="取 消" style="font-size: 40px; color: #000000" onclick="javascript:history.back();" />
</div>
</center>
</p>
</form>
public class AnnounceAction extends BaseAction {
protected TXxzwzxAnnouncement announce;
protected TXxzwzxAnnouncementDAO announceDAO;
protected AnnounceService announceService;
private List<Setting> settingList;
public String initAdd() throws Exception {
this.setTitle("发布公告");
this.setInfo("请填写公告内容。标有 * 号的为必填项。");
return "add";
}
public String add(){
announce.setCAcip(remoteAddr);
Object[] values = new Object[6];
System.out.println("getCAtitle:"+sss);
values[0] = announce.getCAtitle();
values[1] = announce.getCAcontent();
values[2] = announce.getCAclass();
values[3] = announce.getCAcuser();
values[4] = announce.getCAcip();
values[5] = announce.getNAstates();
for(int i=0;i<values.length;i++){
System.out.println(values[i]);
}
Integer i = announceService.addAnnounce(values);
System.out.println("t i="+i);
announce.setNAid(i);
System.out.println("this.aid:"+announce.getNAid());
Short state = announce.getNAstates();
return SUCCESS;
}
............
}
$(function() {
$("input:button, input:submit", ".demo").button();
$( "#dzddraft", ".demo" ).click(function() {
var NAstates = document.getElementById("announce.NAstates").value;
var CAtitle = document.getElementById("announce.CAtitle").value;
var CAclass = document.getElementById("announce.CAclass").value;
var xhrArgs = {
//form: dojo.byId("addform"),
//headers: {
// "Content-Type": "application/x-www-form-urlencoded",
// "Content-Encoding": "GBK"
//},
//postData: encodeURIComponent("announce.CAtitle="+CAtitle);
url: "addDefaultannounce.action",
postData: "announce.NAstates="+NAstates+"&announce.CAtitle="+CAtitle+"&announce.CAclass="+CAclass+"&announce.CAcontent="+GetContents()+"&ajaxRequest=1",
handleAs: "text",
load: function(data) {
dojo.byId("response").innerHTML = "<font color=blue>草稿保存成功!</font>";
},
error: function(error) {
dojo.byId("response").innerHTML = "<font color=red>出错了!</font>";
}
}
dojo.byId("response").innerHTML = "Form being sent..."
var deferred = dojo.xhrPost(xhrArgs);
return false;
});
});