cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to create map attribute using *-items.xml ?

Former Member
0 Likes
2,408

Hi Team,

I have a requirement to create an attribute of Map> type for my productConcept model. I was trying to do like the below one and other 2 ways

 <maptype code="ParamTypeMap"
                 argumenttype="java.lang.String"
                 returntype="java.util.List"
                 autocreate="true"
                 generate="false"/>



but if I am adding Java.util.List in my items.xml file then always its giving build error : list is not a valid type.

So please suggest me how I can create a map type attribute.

Thanks, Kesari Sapient corporation.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Kesari,

You need to define something like this

 <collectiontypes>

 <collectiontype code="MyListCode" elementtype="java.lang.String" autocreate="true" generate="true"
                     type="list"/>
 </collectiontypes>



 <maptype code="ParamTypeMap" argumenttype="java.lang.String"
         returntype="MyListCode" generate="true" autocreate="true" />
 </maptypes>

In the collection MyListCode you can define element type corresponding to the type you are going to store in the list collection.

Thanks,

Former Member
0 Likes

Thanks Vikramjit for your reply.

I have implemented the code as you have mentioned and it's working fine.

Kesari, Tech L2, Sapient Corporation

Former Member
0 Likes

Kindly accept the answer if it solves your problem :d

Answers (1)

Answers (1)

raghavendra_desu
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Jena,

As per above map type definition, you are trying to create a map with String as key and value as a list object, as Hybris created its collection types you try creating a collection type with your required type and create the map type with the string and collection type, which will resolves the issue.

Regards,

Raghavendra.

Former Member
0 Likes

Thanks Raghavendra for your response.

I implemented the code as you have mentioned and it worked fine.

Thanks again.

Kesari