如何在另一个控制器的侧面显示页面中使用控制器的分页?

时间:2010-08-31 12:10:51

标签: grails groovy

如何在另一个控制器的侧显示页面中使用控制器的分页 这是我的代码:

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>

我的代码中有什么错误??????数据出现,但当我点击进入第二个pagenation页面时出现null id错误

1 个答案:

答案 0 :(得分:1)

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