2012-05-08 2 views
0

これは私の最初の質問です!JasperReports:Strutsプラグインがパラメータとしてマップを渡す

StrutsアクションからMapにパラメータとしてMapを渡そうとしています。私はjrxmlファイルに渡されている、reportParametersマップにマップを挿入しました。

私の質問は、jrxmlファイル内でこのマップを取得できるかどうかです。

もっと正確に言うと、私はこのようにそれを宣言します。

<parameter name="reportParams.testMap" class="java.util.Map"/> 

と、私はこのようにそれを使用したい:

<textField> 
    <reportElement style="StyleData" x="240" y="0" width="100" height="23"/> 
    <textElement textAlignment="Left" verticalAlignment="Top"/> 
    <textFieldExpression><![CDATA[testMap.get("AR")]]></textFieldExpression> 
</textField> 

それは可能ですか?

No such property: testMap for class: Blank32A4_1336385977531_38171 
Error evaluating expression : Source text : testMap.get("AR") 
Error evaluating expression : Source text : testMap.get("AR") 

マイアクションクラスは次のようになります:私は自分のアプリケーション・サーバーのログに、このエラーを取得しておくので

@Injectable 
@Results({ 
@Result(name = "success", type = "jasper", params={"location", 
    "report.jasper", 
    "connection", "statsConnection", 
    "dataSource", "translations", 
    "reportParameters","reportParams", 
    "format","PDF"}) 
}) 
public class LocalMapStatisticNewAction extends ActionSupport{ 

    ... 

    public String execute() { 
      reportParams = new Hashtable<String, Object>(); 
      testMap = new Hashtable<String, String>(); 
      testMap.put("AR", "Argentina"); 
      testMap.put("ES", "Spain"); 
      reportParams.put("testMap", testMap); 

      //Jasper code here 
    } 

    ... 

    public Map<String, Object> getReportParams() { 
     return reportParams; 
    } 
} 

任意のヒントが参考になります!

答えて

0

パラメータを間違った名前で参照するのと同じくらい簡単かもしれないようです。

testMap.get("AR") 

testMapというパラメータはありません。 reportParams.testMapというパラメータがあります。また、あなたはこのようなパラメータを参照する必要があります。

$P{testMap}.get("AR") 

は、パラメータの名前を変更またはパラメータへの参照の名前を変更し、[OK]をする必要があります。