action
public void getNoticeTypeAuthority(){
List<Map<String,Object>> noticeTypeList = codeManager.findNodeListForMap
(SystemConstants.SYS_CODE_ENAME_NOTICE_TYPE, null, null, null);
String noticeAuthority = this.getSysParameter();
List<Map<String,Object>> noticeAuthoritylist = noticeManager.findNoticeList(noticeTypeList,noticeAuthority);
try {
HttpServletResponse response = ServletActionContext.getResponse();
response.getWriter().print(JSONArray.fromObject(noticeAuthoritylist).toString());
} catch (IOException e) {
e.printStackTrace();
}
}
jsp
function initRadio(){
var noticeType = document.getElementById("noticeType").value;
var radio="";
var retValue = $.ajax({
async:false,
type: "POST",
url: "sys-notice!getNoticeTypeAuthority.action",
success: function(msg){
//alert( "Data Saved: " + msg );
}
}).responseText;
//alert("retValue" + retValue);
if(retValue == ""){
alert("获取公告类型失败。");
return;
}
// 解析json对象
var dataObj = eval("("+retValue+")");
$.each(dataObj,function(idx,item){
if(noticeType == item.nodeCode){
radio += "<input type='radio' name='notice.noticeType' value='"+item.nodeCode+"'
checked>"+item.nodeName+" ";
}else{
radio += "<input type='radio' name='notice.noticeType' value='"+item.nodeCode
+"'>"+item.nodeName+" ";
}
});
$("#radioObj").html(radio);
}
-------------------------------------------------------------
-------------------------------------------------------------
action
public void getContactAppPermitSelect(){
String contactAppPermit = SystemAdapter.getSysParamCommByCode(SpringContextHolder.getApplicationContext(),
SystemConstants.SYS_PERMIT_CONFIG_CONTACT);
List<Map<String,Object>> nodeList = SystemAdapter.getSysCodeNodeList(SpringContextHolder.getApplicationContext(),
SystemConstants.SYS_CODE_ENAME_APP_TYPE, null, null, null);
List<Map<String,String>> sysPermitlist = contactManager.findContactAppList(nodeList,contactAppPermit,true);
try {
HttpServletResponse response = ServletActionContext.getResponse();
response.getWriter().print(JSONArray.fromObject(sysPermitlist).toString());
} catch (IOException e) {
e.printStackTrace();
}
}
jsp
function initSelect(url,property,value){
var select = "";
select = "<select name='"+property+"' style='width:147px;'>";
select += "<option value=''>-请选择-</option>";
var retValue = $.ajax({
async:false,
type: "POST",
url: url,
success: function(msg){
//alert( "" + msg );
}
}).responseText;
// 解析json对象
var dataObj = eval("("+retValue+")");
if(dataObj==""){
select += "<lect>";
$("#selectObj").html(select);
return;
}
$.each(dataObj,function(idx,item){
if(value==item.code){
select += "<option value='" +item.code+ "' selected='selected'>"+item.name+"</option>";
}else{
select += "<option value='" +item.code+ "'>"+item.name+"</option>";
}
});
select += "</select>";
$("#selectObj").html(select);
}