• Post Reply Bookmark Topic Watch Topic
  • New Topic

Don't know what to pass to a method that takes a generic parameter type.  RSS feed

 
Ramin Esfandiari
Greenhorn
Posts: 16
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

This should be really basic stuff but I cannot think of anyway to solve this without ruining everything else, so here it goes:
I am trying to call a method with the following signature:

I call this method in the following way and the only thing the compiler does not like is the first parameter:

And it gives me the following error:
The method visitParents(Class"<"C">", IVisitor"<"C,R">") in the type Component is not applicable for the arguments (Class<SortableTable>, IVisitor<Component,Void>)
The class SortableTable is as follows:

If you are wondering what DataTable is, it is a Wicket 6 class so google the API if you want to know more about it.

What can I pass to as the first parameter so the method would compile?

Many thanks
Ramin
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know the problem is in first parameter? Can you show visitor?
 
Ramin Esfandiari
Greenhorn
Posts: 16
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't remember what I did that made me believe that the issue is the first parameter but now that you mentioned it, when I change the second parameter to null it compiles fine. I am kinda confused now.
This is my visitor:
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well since C extends MarkupContainer and Component doesn't extend MarkupContainer , you cannot do this, right?



So, you won't be able to pass visit to a parameter that expects IVisitor <MarkupContainer, Void>
 
Ramin Esfandiari
Greenhorn
Posts: 16
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Makes sense, thank you.
 
Ramin Esfandiari
Greenhorn
Posts: 16
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The solution is changing component to SortableTable:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!