Announcement Announcement Module
Collapse
No announcement yet.
How do I manipulate a model java.util.Map object in a JSP page? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I manipulate a model java.util.Map object in a JSP page?

    Hi,

    I'm using Spring 3.1.1.RELEASE and building a web application. I'm struggling to figure out how I manipulate a java.util.Map (via a JSP) that I want to put in my Model. Here is the method that will serve the JSP page ...

    Code:
        @RequestMapping(method = RequestMethod.GET)
        public ModelAndView get(final Model model, final Principal principal) 
        {
    		...
    		final List<Contract> contracts = m_contractSvc.findContractByOrg(orgId);
    		final Map<Contract, Boolean> activeContractsMap = new LinkedHashMap<Contract, Boolean>();
    		...
    		model.addAttribute("contractsMap", activeContractsMap);
    		return new ModelAndView("select");
        }   // getProgramSelect

    I would like the Map to be displayed in a series of checkboxes with the label being the key's "name" field. Here's how I plan to process the data ...

    Code:
        @RequestMapping(method = RequestMethod.POST)
        public ModelAndView registerForPrograms(@ModelAttribute("contractsMap") final Map<Contract, Boolean> activeContractsMap,
                                                final Principal principal) 
        {
    		
    Thanks, - Dave
Working...
X