Grails - 发送重定向参数中的对象列表

时间:2016-06-16 05:55:56

标签: grails groovy

我的问题是我想在索引视图上预览数据而不在数据库中保存数据。为此,我想在重定向的参数段中发送对象列表。并且在接收动作时想要使用该对象列表。但是当我包括如下

def preview(){
//some code
redirect action: "index", params:[planId:params.planId, beamsInfoList: beamsInfoList]
}

我希望发生类似下面的事情。

def index() { 
    //some code
    try{

        planInfo.beamInfo = (params.beamsInfoList==null)?planInfo.beamInfo:params.beamsInfoList //beamInfo is also list

        //some code

    Object[] obj = GRMUtils.calculateTotalBeamsPower(planInfo.beamInfo)
    totalPlanPower = (Float)obj[0];
    beamPowerMap= (Map<Integer, String>)obj[1];
    AmMapUtility utility=new AmMapUtility()
    output = utility.generateAMmapFromBeams(planInfo.beamInfo, GRMConstants.POWER_MAP_PAGE);
    if(null==output){
        flash.error = message(code: 'beammap.noinfoerror.message')
    }
    }catch(Exception e){
    log.error "Excepton occured while loading Power Map", e
}
    respond beams, model:[centerLong:output.getCenterLongitude(),centerLat:output.getCenterLatitude(),amMapImageProperty:output.getMapImages(),
        amMapLinesProperty:output.getMapLines(), planId:params.planId, planInfo:planInfo, powersControlCarrier: powersControlCarrier, powersTrafficCarrier:powersTrafficCarrier,satPower: planInfo.satellite.satelliteMaxPower, totalPlanPower: totalPlanPower, gatewayPower: planInfo.gateway.gatewayAggregateEIRP,fesOutputPowerLimit:fesOutputPowerLimit, beamPowerMap: beamPowerMap,powerRangeColorMap:output.getReuseColorMap()]

}

它不会重定向到索引方法,也不会显示任何错误。两个动作都在同一个控制器中。我曾经使用过闪存,但它没有帮助,因为第二次请求反映了价值。我也尝试了会话,但我收到了错误

org.hibernate.LazyInitializationException: could not initialize proxy - no Session

对某些数据库提取。我被卡住了。我是grails和groovy的新手。请帮忙。

编辑:我发现我的列表很大,这就是为什么它没有重定向。请帮助我另一种选择,比如如果可能的话我如何使用请求属性?

1 个答案:

答案 0 :(得分:1)

我想我已经解决了这个问题。它现在正在工作。我需要做的就是将请求setattribute用作

request.beams = beams

并且不需要在重定向的参数中传递列表,这是我以前习惯做的。我没有使用重定向,而是使用了以下内容:

request.beams = beams

forward action: "index", params:[planId:params.planId]