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

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

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

    asdtiang的博客 感謝blogjava提供的博客交流平臺(tái)

    grails ajax分頁標(biāo)簽實(shí)現(xiàn)--不帶參數(shù)續(xù)傳的
    http://m.tkk7.com/asdtiang/archive/2010/11/26/339127.html



    這次有了新的需求,比如說在結(jié)果中查詢--查詢結(jié)果用的是這個(gè)分頁,那么參數(shù)不繼續(xù)傳的話,就會(huì)出錯(cuò)了
    只是更改了上次的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
            
    //獲取其它的參數(shù)
            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>
                        
    """
            }

            
    ////數(shù)據(jù)信息輸出
            writer<<"""<span id="ajaxPageInfo">當(dāng)前${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">轉(zhuǎn)到<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>"
            
            
    ////每頁顯示幾條數(shù)據(jù)
            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>"
        }

        
    }








    天蒼蒼,野茫茫,風(fēng)吹草底見牛羊

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     

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

    Copyright © asdtiang

    asdtiang的博客 PaidMailz
    點(diǎn)擊廣告網(wǎng)賺A(每天4個(gè)廣告,每個(gè)0.0025美元,一個(gè)搜索廣告0.03美元)
    主站蜘蛛池模板: 国产成人无码免费网站| 日韩免费高清一级毛片| 久久国产免费观看精品3| 亚洲色无码一区二区三区| 一级毛片免费在线观看网站| 亚洲AⅤ无码一区二区三区在线 | 亚洲国产日韩在线观频| 婷婷亚洲综合五月天小说在线| 热99re久久免费视精品频软件| 亚洲日日做天天做日日谢| 在线jyzzjyzz免费视频| 国产精品亚洲专区无码牛牛| 久久精品国产亚洲Aⅴ蜜臀色欲| 亚欧洲精品在线视频免费观看| 色久悠悠婷婷综合在线亚洲| 十八禁视频在线观看免费无码无遮挡骂过| 亚洲啪啪综合AV一区| 久久久99精品免费观看| 亚洲精品成人网站在线播放| 国产在线国偷精品产拍免费| 亚洲国产精品高清久久久| 免费观看91视频| 亚洲中文字幕久在线| 成人人观看的免费毛片| 永久免费无码日韩视频| 国产亚洲一区二区精品| 1000部国产成人免费视频| 亚洲hairy多毛pics大全| 亚洲国产精品人人做人人爱| a在线视频免费观看在线视频三区 a毛片成人免费全部播放 | 老司机午夜免费视频| 亚洲国产精品无码久久久不卡| 久久免费看黄a级毛片 | 亚洲国产精华液网站w| 免费看美女裸露无档网站| 西西人体大胆免费视频| 中文字幕亚洲精品资源网| 日韩成人在线免费视频| 在线观看免费播放av片| 亚洲一本一道一区二区三区| 亚洲精品美女久久久久99|