2010-08-31 48 views
1

如何使用pagenation與另一個控制器 的一面展現頁面控制器,這是我的代碼:pagenation問題

plan controller: 
def show = { 
    if (!params.max) params.max = 4 
    if (!params.offset) params.offset = 0 
    def planInstance = Plan.get(params.id) 

    def planVoiceServiceListCount = PlanVoiceService.countByPlan(planInstance) 
    def planVoiceServiceList = PlanVoiceService.findAllByPlan(planInstance, [max: params.max as Integer, offset: params.offset as Integer]) 

    if (!planInstance) { 
    flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'plan.label', default: 'Plan'), params.id])}" 
    redirect(action: "list") 
    } 
    else { 

    [planInstance: planInstance, 
    planVoiceServiceList: planVoiceServiceList, 
    planVoiceServiceListCount: planVoiceServiceListCount] 
    } 
} 

,並計劃\ show.gsp:

<div class="dialog"> 
    <table align="left"> 
    <thead> 

    <tr>  
     <th>${message(code:'plan.services.voice.label', default:'Voice Service Name') }</th> 
     <th>${message(code:'plan.services.voice.label', default:'Voice Service Description') }</th> 
     <th>${message(code:'plan.services.voice.maxsessions.label', default:'Max Simultaneous Calls') }</th> 
     <th>${message(code:'plan.services.voice.tariff.label', default:'Voice Tariff') }</th> 
     <th>${message(code:'plan.services.voice.services.label', default:'Calling Destination Group') }</th> 
     <th>${message(code:'plan.services.voice.services.label', default:'Plan Voice Service Minute') }</th> 
     <th>${message(code:'plan.services.voice.services.label', default:'Plan') }</th> 
    </tr> 
    </thead> 
    <tbody> 
    <g:each in="${planVoiceServiceList}" status="i" var="planVoiceServiceInstance"> 
     <tr class="${(i % 2) == 0 ? 'odd' : 'even'}"> 
     <gsec:hasRole name='Administrator'> 
     <td><gti:link controller = "planVoiceService" action="show" id="${planVoiceServiceInstance.id}">${fieldValue(bean: planVoiceServiceInstance, field: "voiceService.name")}</gti:link></td> 
     </gsec:hasRole> 
     <gsec:hasRole name='Company'> 
     <td>${fieldValue(bean: planVoiceServiceInstance, field: "voiceService.name")}</td> 
     </gsec:hasRole> 
     <td>${fieldValue(bean: planVoiceServiceInstance, field: "voiceService.description")}</td> 
     <td>${fieldValue(bean: planVoiceServiceInstance, field: "maxSessions")}</td> 
       <gsec:hasRole name='Administrator'>   
     <td><g:link controller="voiceTariff" action="show" id="${planVoiceServiceInstance.voiceTariff.id}">${fieldValue(bean: planVoiceServiceInstance, field: "voiceTariff.description")}</g:link></td> 
    </gsec:hasRole> 
     <gsec:hasRole name='Company'>   
     <td>${fieldValue(bean: planVoiceServiceInstance, field: "voiceTariff.description")}</td> 
    </gsec:hasRole> 
     <td>${fieldValue(bean: planVoiceServiceInstance, field: "callingDestinationGroup.name")}</td> 
     <td>${fieldValue(bean: planVoiceServiceInstance, field: "planVoiceServiceMinute")}</td> 


     <td>${fieldValue(bean: planVoiceServiceInstance, field: "plan.description")}</td> 


     </tr> 
    </g:each> 
    </tbody> 

    </table><br /><br /><br /><br /> 
    <div class="paginateButtons"> 
    <g:paginate controller="plan" action="show" 
     total="${planVoiceServiceListCount}" 
     > 
    </g:paginate> 
    </div> 

什麼是錯誤的我的代碼??????數據appers但是當我點擊進入第二pagenation頁空ID錯誤出現

回答

1
<g:paginate controller="plan" action="show" id="${planInstance.id}" 
     total="${planVoiceServiceListCount}" 
     > 
+0

非常感謝它正在 – mhmd 2010-09-01 09:24:29

+1

你能標記答案接受?如果你這樣做的話,人們會對你的問題更加敏感。 – 2010-09-01 12:05:11

+0

它正在工作,但仍然有一個問題發生,我有2個列表中的顯示頁面,當我點擊頁面的頁面按鈕之一的2列表轉到第二頁。有沒有辦法解決這個問題? – mhmd 2010-09-02 08:24:37