Announcement Announcement Module
No announcement yet.
Spring Portlet MVC / Command Objects Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Portlet MVC / Command Objects

    I am creating a portlet that consists of 3 pages and am utilizing the AbstractWizardFormController to accomplish this. The intial page displays a list of items that the user can select by selecting a check box in the corresponding row.

    The subsequent page displays another list of items that are dependent on the selection from the first page.

    My referenceData() method looks like this:
    	protected Map referenceData(PortletRequest request, Object command,
    			Errors errors, int page) throws Exception {
    		Map<String, Object> referenceData = new HashMap<String, Object>();
    		PortletSession session = request.getPortletSession();
    		// call the allocation web service if it's the first page
    		if (page == 0) {
    			List<Allocation> allocations = getHcpAllocations(session);
    			referenceData.put("targetedAllocations", allocations);
    		// call the service to get the list of shipping addresses
    		if (page == 1) {
                          //process indexes and get the list of addresses based on that
    		return referenceData;
    I planned on creating a hidden form field and append the indexes of the allocations to each other using javascript and then in the referenceData method process those indexes to get the shipping addresses. I'm assuming that the hidden field will be available as a request parameter when the referenceData method is called the second time. Is this a correct assumption?

  • #2
    So, the AbstractWizardFormController is intended for filling out a single command object across multiple pages. If that is what you are wanting to do, then the values set on the first page will already be in your command object as you render the second page and you can use that data to customize it as needed.

    If instead you are going through a process of making some selections that are not part of the ultimate command object, then you probably don't want to try and do it all from a single controller. Instead build one controller to make the selections and then a second one that gets the customization from the selections via it's referenceData.

    Or, better yet, switch from the interface-based Controllers to using Annotation-based Controllers, and then the flow of things is much more up to you.