I am not sure if this is a complex problem but as a starting person this seems a bit complex to me.
I have an object based on which i need to show some values on the UI and let user select some of them, i need to send data back to another controller when user click on the submit button.Here is the structure of my data object
public class PrsData{
private Map<String, List<PrsCDData>> prsCDData;
}
public class PrsCDData{
private Map<String, Collection<ConfiguredDesignData>> configuredDesignData;
}
public ConfiguredDesignData{
// simple fields
}
I have set the object in model before showing the view like
model.addAttribute("prsData", productData.getPrData());
In the form i have following settings
<form:form method="post" commandName="prsData" action="${addProductToCartAction}" >
<form:hidden path="prsCDData['${prsCDDataMap.key}']
[${status.index}].configuredDesignData['${configuredDesignDataMap.key}']
[${configuredDesignDataStatus.index}].code"/>
<form:hidden path="prsCDData['${prsCDDataMap.key}']
[${status.index}].configuredDesignData['${configuredDesignDataMap.key}']
[${configuredDesignDataStatus.index}].description"/>
</form:form>
This is what i have at AddProductToCartController
public String addToCart(@RequestParam("productCodePost") final String code,
@ModelAttribute("prsData") final PrsData prsData, final Model model,
@RequestParam(value = "qty", required = false, defaultValue = "1") final long qty)
On submitting the form i am getting following exception
org.springframework.beans.NullValueInNestedPathException: Invalid property 'prsCDData[Forced][0]'
of bean class [com.product.data.PrsData]:
Cannot access indexed value of property referenced in indexed property path 'prsCDData[Forced][0]': returned null
It seems like its trying to access the values on this controller while i am trying to send value to that controller and trying to create same object with selected values
Can any one tell me where i am doing wrong and what i need to take care of