关于ajax选中头标签功能

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;
    }



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值