您的位置:首页 > 其它

关于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;

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ajax 标签