`
biaoming
  • 浏览: 266288 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

想做个pagination的java版

    博客分类:
  • ruby
阅读更多
       def pagination_links_each(paginator, options)  
         options = DEFAULT_OPTIONS.merge(options)  
         link_to_current_page = options[:link_to_current_page]  
         always_show_anchors = options[:always_show_anchors]  
         current_page = paginator.current_page  
         window_pages = current_page.window(options[:window_size]).pages  
         return if window_pages.length <= 1 unless link_to_current_page  
         first, last = paginator.first, paginator.last  
         html = ''  
         if always_show_anchors and not (wp_first = window_pages[0]).first?  
           html << yield(first.number)  
           html << ' ... ' if wp_first.number - first.number > 1  
           html << ' '  
         end  
         window_pages.each do |page|  
           if current_page == page && !link_to_current_page  
             html << page.number.to_s  
           else  
             html << yield(page.number)  
           end  
           html << ' '  
         end  
         if always_show_anchors and not (wp_last = window_pages[-1]).last?   
           html << ' ... ' if last.number - wp_last.number > 1  
           html << yield(last.number)  
         end  
         html  
       end 
 

这会产生一个比较好看的视觉,至少我觉得,现在想做个JAVA版的,主要是怎么生成html,请各人搞手给个思路,谢谢!

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics