views:

26

answers:

1

I have a portlet which has many rendering and action methods:

@Controller
@RequestMapping("VIEW")
public class CartController {
  @RenderMapping() // default render method
  public String defaultRender(RenderRequest req, RenderResponse res, Model model) throws PortalException, SystemException {
    ...
  }

  @RenderMapping(params="action=showCustInfo")
  public String showCustInfo(RenderRequest req, RenderResponse res, Model model) throws PortalException, SystemException {
    ...
  }

  @ActionMapping(params="action=acceptCart")
public void acceptCart(ActionRequest req, ActionResponse res, Model model) throws PortalException, SystemException {
    ...
    res.setRenderParameter("action", "showCustInfo");
    ...
  }

In the code above, the method acceptCart sets a render parameter that should cause showCustInfo to be called in rendering phase.

The problem is that the default rendering method gets called every time. What am I missing?

A: 

The reason (it seems) was that the action-parameter was not replaced when I commanded

res.setRenderParameter("action", "showCustInfo");

Instead of replacing the value, Spring added this value for the action parameter as follows (pseudo):

// Before:
params['action'] = ['acceptCart'] // all req params in Spring are handled as String arrays..

// After:
params['action'] = ['acceptCart','showCustInfo']

At this point, Spring does not seem to know what to do and calls the default render method. I worked this around by using a different parameter name for the render parameter ('render'). Thus now actions get called by 'action'-parameter and renderers by 'render'-parameter.

heikkim