2

I have to create a JSF composite component where, I have to pass a attribute like below:

<composite:attribute name="noteList" type="XXX" required="true"></composite:attribute>

what should I pass in type attribute if it is a List of type Note class?

I know I can make type="java.util.List", but how can I make it specific to List of type Note?

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
notescrew
  • 3,072
  • 4
  • 21
  • 36

1 Answers1

4

but how can I make it specific to List of type Note

Unfortunately, you can't. It's determined during runtime, during which the generic type information is already lost. Technically, this can be workarounded using reflection trickery, but JSF and EL spec guys may have their own reasons for not specifying it.

Your best bet is to replace it by a custom subclass as below:

public class Notes extends ArrayList<Note> {}
<cc:attribute ... type="com.example.model.Notes" />

But this may require changes in the model.

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452