<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    asdtiang的博客 感謝blogjava提供的博客交流平臺

    grails ajax分頁標簽實現--不帶參數續傳的
    http://www.tkk7.com/asdtiang/archive/2010/11/26/339127.html



    這次有了新的需求,比如說在結果中查詢--查詢結果用的是這個分頁,那么參數不繼續傳的話,就會出錯了
    只是更改了上次的tagLib類:
    代碼如下:
    import org.springframework.web.servlet.support.RequestContextUtils as RCU;
    import org.codehaus.groovy.grails.commons.ConfigurationHolder
    class AjaxPageTagLib {
        def paginateAjax
    ={attrs ->
            def writer 
    = out
            
    //獲取其它的參數
            def params1=new HashMap()
            params1.putAll(params)
            params1.remove(
    "max")
            params1.remove(
    "offset")
            params1.remove(
    "controller")
            params1.remove(
    "action")
            def otherParamsUrl
    =""
            params1.each
    {
                otherParamsUrl
    =otherParamsUrl+it.toString()+"&"
                
                }
            
            params.offset 
    = Math.min(params.offset ? params.offset as int : 0100)
            params.sort
    =params.sort==null?"dateCreated":params.sort
            params.order
    =params.order==null?"desc":params.order
            def messageSource 
    = grailsAttributes.getApplicationContext().getBean("messageSource")
            def locale 
    = RCU.getLocale(request)        
            def total 
    = attrs.total.toInteger()
            def offset 
    = params.offset?.toInteger()
            def max 
    = params.max?.toInteger()
            
    int pageSize=Math.round(Math.ceil(total / max))    
            def path
    =request.getContextPath()    
            def pageNow
    =offset/max+1
            def selectMax
    =attrs.selectMax?.toInteger()
            
    if(!selectMax){
                selectMax
    =20
            }

            
            selectMax
    =selectMax>total?total:selectMax
            
    ////js輸出
            writer<<"""
             <div id="ajaxPage">
            
    """
            /////顯示首頁和上頁
            def firstText=messageSource.getMessage('paginate.first'null, messageSource.getMessage('default.paginate.first'null'First', locale), locale)
            def prevText
    =messageSource.getMessage('paginate.prev'null, messageSource.getMessage('default.paginate.prev'null'Prev', locale), locale)
            def nextText
    =messageSource.getMessage('paginate.next'null, messageSource.getMessage('default.paginate.next'null'Next', locale), locale)
            def lastText
    =messageSource.getMessage('paginate.last'null, messageSource.getMessage('default.paginate.last'null'Last', locale), locale)
            
            
    if(offset!=0){
                def firstUrl
    ="""${otherParamsUrl}offset=0&max=${params.max}"""
                writer
    <<"""
                <span id="firstShow" title="${firstText}" onclick="new Ajax.Updater('${attrs.update}',
            '${path}/${params.controller}/${params.action}',{asynchronous:true,evalScripts:true,parameters:'${firstUrl}'});
            
    return false;" >
                [${firstText}]
                
    </span>
                
    """
                int prev=offset-max
                def prevUrl
    ="""${otherParamsUrl}offset=${prev}&max=${params.max}"""
                writer
    <<"""
                    <span id="preShow" title="${prevText}" onclick="new Ajax.Updater('${attrs.update}',
                '${path}/${params.controller}/${params.action}',{asynchronous:true,evalScripts:true,parameters:'${prevUrl}'});
                
    return false;" >
                    [${prevText}]
                    
    </span>
                    
    """
            }

            
    else{
                writer
    <<"""<span id="firstNoShow" title="${firstText}">
                          [${firstText}]
                          
    </span>
                    
    """
                writer<<"""<span id="preNoShow" title="${prevText}">
                        [${prevText}]
                        
    </span>
                        
    """
            }

            
    ////數據信息輸出
            writer<<"""<span id="ajaxPageInfo">當前${pageNow}/${pageSize}頁(共${total})</span>"""
            
            
    //下一頁和末頁輸出,
            if(offset!=max*(pageSize-1)){
                
    int next1=offset+max
                def nextUrl
    ="""${otherParamsUrl}offset=${next1}&max=${params.max}"""
                
                writer
    <<"""
                    <span id="nextShow"   title="${nextText}" onclick="new Ajax.Updater('${attrs.update}',
                '${path}/${params.controller}/${params.action}',{asynchronous:true,evalScripts:true,parameters:'${nextUrl}'});
                
    return false;" >
                    [${nextText}]
                    
    </span>
                    
    """
                int last=max*(pageSize-1)
                def lastUrl
    ="""${otherParamsUrl}offset=${last}&max=${params.max}"""
                writer
    <<"""
                    <span id="lastShow" title="${lastText}" onclick="new Ajax.Updater('${attrs.update}',
                '${path}/${params.controller}/${params.action}',{asynchronous:true,evalScripts:true,parameters:'${lastUrl}'});
                
    return false;" >
                    [${lastText}]
                    
    </span>
                    
    """
            }

            
    else{
                writer
    <<"""<span id="nextNoShow" title="${nextText}">
                    [${nextText}]
                    
    </span>
                    
    """
                writer<<"""<span id="lastNoShow" title="${lastText}">
                    [${lastText}]
                    
    </span>
                    
    """
            }

            
    ///到指定頁連接輸出
            def selectUrl="&${otherParamsUrl}max=${params.max}"
            writer
    <<"""
            <span id="ajaxSelectText">轉到<select id="ajaxSelect" onchange="myUpdate('${attrs.update}','${path}/${params.controller}/${params.action}'
            ,'${selectUrl}','${max}')">
            
            
    """
            for(int j=1;j<=pageSize;j++){
                
    if(pageNow!=j){
                    writer
    <<"""  <option value ="${j}">${j}/${pageSize}</option>           """
                }

                
    else{
                    writer
    <<"""  <option value ="${j}"  selected="selected">${j}/${pageSize}</option>           """
                }

            }

            writer
    <<"</select>頁</span>"
            
            
    ////每頁顯示幾條數據
            def maxUrl="&${otherParamsUrl}offset=0"
            writer
    <<"""
                 <span id="ajaxMaxText"> 每頁顯示</span><select id="ajaxMax" onchange="myUpdate2('${attrs.update}','${path}/${params.controller}/${params.action}'
                ,'${maxUrl}')">
                """
            for(int j=1;j<=selectMax;j++){
                
    if(max!=j){
                    writer
    <<"""<option value ="${j}">${j}</option>"""
                }

                
    else{
                    writer
    <<"""<option value ="${j}"  selected="selected">${j}</option>"""
                }

            }

            writer
    <<"</select> </div>"
        }

        
    }








    天蒼蒼,野茫茫,風吹草底見牛羊

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    posts - 80, comments - 24, trackbacks - 0, articles - 32

    Copyright © asdtiang

    asdtiang的博客 PaidMailz
    點擊廣告網賺A(每天4個廣告,每個0.0025美元,一個搜索廣告0.03美元)
    主站蜘蛛池模板: 特级毛片全部免费播放| 亚洲色丰满少妇高潮18p| 污污免费在线观看| 大学生一级特黄的免费大片视频| 亚洲国产精品婷婷久久| 久久午夜夜伦鲁鲁片免费无码| 亚洲中文字幕在线观看| 91在线免费观看| 久久精品国产精品亚洲艾| 免费无码毛片一区二区APP| 久久久久久久尹人综合网亚洲| 中国一级特黄高清免费的大片中国一级黄色片 | 亚洲高清日韩精品第一区| 久久中文字幕免费视频| 亚洲国产精品自在在线观看| 99久热只有精品视频免费看 | 久久激情亚洲精品无码?V| 一级一看免费完整版毛片| 伊伊人成亚洲综合人网7777| 久热免费在线视频| 亚洲精品国产电影午夜| 大学生美女毛片免费视频| 男人j进女人p免费视频| 相泽亚洲一区中文字幕| 久久成人无码国产免费播放| 亚洲乱码在线播放| 免费国产人做人视频在线观看| 拍拍拍无挡视频免费观看1000| 久久亚洲私人国产精品| 成人毛片免费视频| eeuss在线兵区免费观看| 久久精品国产亚洲av麻豆色欲 | 91精品免费观看| 亚洲精品无码你懂的| 国产亚洲美日韩AV中文字幕无码成人 | 特级毛片aaaa免费观看| 亚洲AV日韩精品久久久久久| 久久电影网午夜鲁丝片免费| jizz免费在线观看| 91亚洲国产成人久久精品| 亚洲成a人片在线播放|