关于ajax选中头标签功能
2015-08-20 12:35
225 查看
1.点击编辑标签进入此框
在编辑按钮页面增加
$("#add_to_folder_btn").click(function(){
if(smate.pubinspg.selectGroupPubIds().length==0){
$.smate.scmtips.show('warn', "请先选择成果!");
return false;
}
$("input:checked[name='moveToFolders']").attr("checked",false);
var des3PubIds =selectPubIds();
var datajson = {"des3PubIds":des3PubIds,"des3InspgId":parent.getDes3InspgId()};
$.ajax( {
url : '/pubweb/inspg/ajaxgetfolderids',
type : 'post',
dataType:'json',
data : datajson,
success : function(data) {
selectedfolderid(data.result);
$("#showAddToFolderDiv").attr("alt","/#TB_inline?height=265&width=430&inlineId=pubAddFolderDiv");
$("#showAddToFolderDiv").click();
},
error: function (data, status, e){
$.smate.scmtips.show('warn',data.msg);
}
});
2.在action页面增加
/**
* @throws PubException
* ajax请求获取选中的pubid对应的folderid列表
*
* @author
* @return
* @throws
*/
@Action("/pubweb/inspg/ajaxgetfolderids")
public void ajaxgetfolderids() throws PubException{
Map<Object, Object> map = new HashMap<Object, Object>(4);
form.setInspgId(NumberUtils.toLong(ServiceUtil.decodeFromDes3(form.getDes3InspgId())));
form.setPubIds(form.getDes3PubIds());
List<Long> list=pubInspgFolderService.getPubInspgFolderList(form);
map.put("result", list);
Struts2Utils.renderJson(map, "encoding:UTF-8");
}
3.添加在service层添加getPubInspgFolderList()方法
/**
* 获取 主页选中的成果对应标签列表
* @param inspgId
* @return
*/
List<Long> getPubInspgFolderList(PubInspgForm form) throws PubException ;
4.在impl中实现
@Override
public List<Long> getPubInspgFolderList(PubInspgForm form) throws PubException {
List<Long> list=pubInspgFolderDao.getPubInspgFolderList(form.getInspgId(), form.getPubIds());
return list;
}
5.实现getPubInspgFolderList(form.getInspgId(), form.getPubIds())
@SuppressWarnings("unchecked")
public List<Long> getPubInspgFolderList(Long inspgId,String pubids)
throws PubDaoException {
String[] pubIds=pubids.split(",");
List<Long> lists =new ArrayList<Long>();
for(int i=0;i<pubIds.length;i++){
String hql = "from PubInspgFolderUnion t where t.inspgId = ? and t.pubId=?";
List<PubInspgFolderUnion> list=super.createQuery(hql, inspgId,NumberUtils.toLong(ServiceUtil.decodeFromDes3(pubIds[i]))).list();
for(PubInspgFolderUnion pubunion:list){
lists.add(pubunion.getFolderId());
}
}
return lists;
}
在编辑按钮页面增加
$("#add_to_folder_btn").click(function(){
if(smate.pubinspg.selectGroupPubIds().length==0){
$.smate.scmtips.show('warn', "请先选择成果!");
return false;
}
$("input:checked[name='moveToFolders']").attr("checked",false);
var des3PubIds =selectPubIds();
var datajson = {"des3PubIds":des3PubIds,"des3InspgId":parent.getDes3InspgId()};
$.ajax( {
url : '/pubweb/inspg/ajaxgetfolderids',
type : 'post',
dataType:'json',
data : datajson,
success : function(data) {
selectedfolderid(data.result);
$("#showAddToFolderDiv").attr("alt","/#TB_inline?height=265&width=430&inlineId=pubAddFolderDiv");
$("#showAddToFolderDiv").click();
},
error: function (data, status, e){
$.smate.scmtips.show('warn',data.msg);
}
});
2.在action页面增加
/**
* @throws PubException
* ajax请求获取选中的pubid对应的folderid列表
*
* @author
* @return
* @throws
*/
@Action("/pubweb/inspg/ajaxgetfolderids")
public void ajaxgetfolderids() throws PubException{
Map<Object, Object> map = new HashMap<Object, Object>(4);
form.setInspgId(NumberUtils.toLong(ServiceUtil.decodeFromDes3(form.getDes3InspgId())));
form.setPubIds(form.getDes3PubIds());
List<Long> list=pubInspgFolderService.getPubInspgFolderList(form);
map.put("result", list);
Struts2Utils.renderJson(map, "encoding:UTF-8");
}
3.添加在service层添加getPubInspgFolderList()方法
/**
* 获取 主页选中的成果对应标签列表
* @param inspgId
* @return
*/
List<Long> getPubInspgFolderList(PubInspgForm form) throws PubException ;
4.在impl中实现
@Override
public List<Long> getPubInspgFolderList(PubInspgForm form) throws PubException {
List<Long> list=pubInspgFolderDao.getPubInspgFolderList(form.getInspgId(), form.getPubIds());
return list;
}
5.实现getPubInspgFolderList(form.getInspgId(), form.getPubIds())
@SuppressWarnings("unchecked")
public List<Long> getPubInspgFolderList(Long inspgId,String pubids)
throws PubDaoException {
String[] pubIds=pubids.split(",");
List<Long> lists =new ArrayList<Long>();
for(int i=0;i<pubIds.length;i++){
String hql = "from PubInspgFolderUnion t where t.inspgId = ? and t.pubId=?";
List<PubInspgFolderUnion> list=super.createQuery(hql, inspgId,NumberUtils.toLong(ServiceUtil.decodeFromDes3(pubIds[i]))).list();
for(PubInspgFolderUnion pubunion:list){
lists.add(pubunion.getFolderId());
}
}
return lists;
}
相关文章推荐
- 解决Ajax悬停效果,无法遮蔽FLASH的问题
- 表格标签table深入了解
- 再谈Jquery Ajax方法传递到action(补充)
- WEB标准网页布局中尽量不要使用的HTML标签
- Dom在ajax技术中的作用说明
- 使用Ajax实时检测"用户名、邮箱等"是否已经存在
- 探讨Ajax中同步与异步之间的区别
- web标准知识――用途相似的标签
- 原生AJAX写法实例分析
- 探秘ajax跨域请求
- Ajax中浏览器和服务器交互详解
- ajax实现点击不同的链接让返回的内容显示在特定div里
- ajax 动态传递jsp等页面使用id辨识传递对象
- AJAX简单应用实例-弹出层
- AJAX初级教程之初识AJAX
- Ajax无刷新分页的性能优化方法
- jquery对ajax的支持介绍
- jQuery基于ajax实现星星评论代码
- Ajax 说的比较清楚的一篇文章
- 强烈推荐 - Ajax 技术资源中心