You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Daniel Young <dy...@synyati.com.au> on 2006/11/10 05:23:51 UTC

Generics in for custom EL function

Hi all,

 

I'm trying to expose the following function in EL:

 

public static String getMessage(final String locale, final Map<String,
Message> messages) {

. . .

}

 

However I'm having trouble specifying the messages parameter in my
taglib.xml, due to the Generic.  I have the following:

 

      <function>

        <function-name>getMessage</function-name>

 
<function-class>com.synyati.spurwing.i18n.entity.Message</function-class>

        <function-signature>java.lang.String
getLocalisedMessage(java.lang.String,
java.util.Map&lt;java.lang.String,com.synyati.spurwing.i18n.entity.Message&g
t;)</function-signature>

      </function>    

 

The &lt; seems to encode fine, but there comma between the String and
Message seems to confuse things.  I get the following:

 

Caused by: java.lang.ClassNotFoundException: java.util.Map<java.lang.String

 

Is this a known error, or can I get around it somehow?

 

 

Cheers,

Daniel.

 


Re: Generics in for custom EL function

Posted by Andrew Robinson <an...@gmail.com>.
Generics aren't present at runtime -- they are a compile time "hack"
in Java. So at run time, your 2nd argument is a Map, nothing special
about it (the generic is no longer visible then). So you will be
correct in not putting the generic definition in the function
definition.

On 11/9/06, Daniel Young <dy...@synyati.com.au> wrote:
>
>
>
>
>
>
>
> PS:  if I remove the generic part from the Map declaration works fine, so
> it's not a biggie…
>
>
>  ________________________________
>
>
> From: Daniel Young [mailto:dyoung@synyati.com.au]
>  Sent: Friday, 10 November 2006 2:24 PM
>  To: users@myfaces.apache.org
>  Subject: Generics in <function-signature> for custom EL function
>
>
>
>
> Hi all,
>
>
>
> I'm trying to expose the following function in EL:
>
>
>
> public static String getMessage(final String locale, final Map<String,
> Message> messages) {
>
> . . .
>
> }
>
>
>
> However I'm having trouble specifying the messages parameter in my
> taglib.xml, due to the Generic.  I have the following:
>
>
>
>       <function>
>
>         <function-name>getMessage</function-name>
>
>
> <function-class>com.synyati.spurwing.i18n.entity.Message</function-class>
>
>         <function-signature>java.lang.String
> getLocalisedMessage(java.lang.String,
> java.util.Map&lt;java.lang.String,com.synyati.spurwing.i18n.entity.Message&gt;)</function-signature>
>
>       </function>
>
>
>
>
> The &lt; seems to encode fine, but there comma between the String and
> Message seems to confuse things.  I get the following:
>
>
>
> Caused by: java.lang.ClassNotFoundException:
> java.util.Map<java.lang.String
>
>
>
> Is this a known error, or can I get around it somehow?
>
>
>
>
>
> Cheers,
>
> Daniel.
>
>

RE: Generics in for custom EL function

Posted by Daniel Young <dy...@synyati.com.au>.
 

PS:  if I remove the generic part from the Map declaration works fine, so
it's not a biggie.

 

  _____  

From: Daniel Young [mailto:dyoung@synyati.com.au] 
Sent: Friday, 10 November 2006 2:24 PM
To: users@myfaces.apache.org
Subject: Generics in <function-signature> for custom EL function

 

Hi all,

 

I'm trying to expose the following function in EL:

 

public static String getMessage(final String locale, final Map<String,
Message> messages) {

. . .

}

 

However I'm having trouble specifying the messages parameter in my
taglib.xml, due to the Generic.  I have the following:

 

      <function>

        <function-name>getMessage</function-name>

 
<function-class>com.synyati.spurwing.i18n.entity.Message</function-class>

        <function-signature>java.lang.String
getLocalisedMessage(java.lang.String,
java.util.Map&lt;java.lang.String,com.synyati.spurwing.i18n.entity.Message&g
t;)</function-signature>

      </function>    

 

The &lt; seems to encode fine, but there comma between the String and
Message seems to confuse things.  I get the following:

 

Caused by: java.lang.ClassNotFoundException: java.util.Map<java.lang.String

 

Is this a known error, or can I get around it somehow?

 

 

Cheers,

Daniel.