Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HashMap Map and useBean

 
U Kvistborg
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a question, regarding this use and generics, or typed collections.

When I do this I ofcourse gets my HashMap, either a new one or if one allready is set on the request as that one.

But my editor keep telling me with a warning that I should parameterize the HashMap

Multiple annotations found at this line:
- HashMap is a raw type. References to generic type HashMap<K,V> should be
parameterized
- HashMap is a raw type. References to generic type HashMap<K,V> should be
parameterized


So my question is how do I do that ? I can not do it as in normal Java with the <> e.g.

guess the <> are seen by the jsp engine as some sort of xml tags within the
jsp:useBean tag.

and using the < and > instead of <> as below

I get this error.

Multiple annotations found at this line:
- Undefined type:
java.util.Map&&;lt;String,String&&;gt;
- Undefined type:
java.util.Map&&;lt;String,String&&;gt;


is it possible to have the Type on collections using useBean ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65537
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why bother? Just ignore the IDE warnings. It's not like it's any error of any type.

Moreover, if the bean is already in scope, there's no need to declare it as anything other than a Map. The fact that it's a HashMap is moot. Set class to java.util.Map, and drop the type attribute.
 
U Kvistborg
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set class to java.util.Map, and drop the type attribute.

guess you mean the other way around ? the class attribute means that it will if there is nothing in scope instantiate it.
But the thing is this map is only set to the request if there is any errors, if there is none or the first time I enter the page the map will not be there. And I can enter this jsp page from several ways.

And it just anoys me all the warnings some times. So I where wondering.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65537
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right.

And, you can turn off warnings in your IDE if they annoy you.
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!