Powered By Blogger

Thursday, January 27, 2011

Storing the complex type in the content model

In the alfresco content model property you can store List, HashMap,Set etc

For this do the below

In your model define the property


d:any


To store the value use the below code

//storing all the selected regions
final HashMap regionMap = new HashMap();
for(String region : selectedRegions){
regionMap.put(region, region);
}
_map.put(PowerGridContentModel.PROP_REGIONS, (Serializable)regionMap);


To retrieve use the below code, I am considering example of getting property from executionContext


HashMap regionsMap = (HashMap) executionContext.getContextInstance().getVariables().get("pcm_regions");
if(regionsMap != null){

for (Map.Entry pair : regionsMap.entrySet()) {

System.out.println("Region name::"+pair.getKey() + " = " + pair.getValue());

}


Hope it helps.

No comments:

Post a Comment