Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

el function with generic arraylist return type and with parameter

Tags:

java

jsp

el

I want to return ArrayList<HashMap<String,String>> in EL function with three String argument. How to do that?

like image 937
Parth Avatar asked Dec 01 '25 01:12

Parth


1 Answers

You can use complex return types in your tld, too. E.g. this will work:

public static List<Map<String, String>> func(String arg1, String arg2,
        String arg3) {

    List<Map<String, String>> out = new ArrayList<HashMap<String, String>>();
    // code code code
    return out;
}

In your .tld file, you'll have to put this:

<function>
  <description>Blah blah blah</description>
  <name>func</name>
  <function-class>your.package.YourClassName</function-class>
  <function-signature>
    java.util.List&lt;java.util.Map&lt;java.lang.String,java.lang.String&gt;&gt; func(java.lang.String,java.lang.String,java.lang.String)
  </function-signature>
</function>

Caveats: As in this example, the angle brackets must be properly escaped in XML. The function signature must not be line wrapped. Non-unary generics, such as Map<String,String>, cannot be used as parameters. (Probably a tokenization bug.) You will have to go with the raw types there.

like image 98
Matthias Ronge Avatar answered Dec 03 '25 13:12

Matthias Ronge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!