Announcement Announcement Module
Collapse
No announcement yet.
Methods not being called in a Spring MVC Portlet Form Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Methods not being called in a Spring MVC Portlet Form

    I have a form in a portlet which has the ACTION defined by this variable:

    <portlet:actionURL var="action">
    <portletaram name="action" value="xxx"/>
    <portletaram name="event" value="yyy"/>
    </portlet:actionURL>

    However, the only method in my SimpleFormController which ever gets called is showForm(), despite the fact that I'm calling an actionURL.

    Can anyone help me understand why none of the form submission or action methods are being called?


    Robert

  • #2
    Hello,

    I am havin the same issue. What steps did you take to resolve this issue.

    Thanks in advance.
    MC

    Comment


    • #3
      You must annotate your Controller's methods with @ActionMapping/@RenderMapping tags in the way it follows

      Code:
      @RequestMapping(value="VIEW")
      @Controller(value="myController")
      public class MyController {
      
      ...
      
      	@ActionMapping(params="action")
      	public void actionDispatcher(@RequestParam("action") String action, 
      								 @ModelAttribute("estadoPedido") EstadoPedidoForm form,
      								 BindingResult bindingResult, Model model,
      								 ActionRequest aRequest, ActionResponse aResponse){
      //your code goes here
      	}
      
      	@RenderMapping(params="action")
      	public String renderDispatcher(@RequestParam("action") String action){
      		String retorno = null;
      		
      		if (action.equals("consultar") || action.equals("return")){
      			retorno = "consultaPedido";
      		}else if(action.equals("irDetallePedido")){
      			retorno = "detallePedido";
      		}else if (action.equals("noDisponible")) {
      			retorno = "noDisponible";
      		}else if(action.equals("error")){
      			retorno = "error";
      		}
      		
      		return retorno;
      	}
      
      }
      No matters your method's names, they will be executed when a Action/Render request is recived and matches with their requirements (i.e. request with a param called "action", or it could be more restrictive: a param called action which value is "doSomething"... etc)
      in this example, both methods acts as dispatchers, doing one or another thing depending on the action parameter value.

      Here you are 2 very instructive links:
      http://books.dzone.com/articles/hell...-3-portlet-MVC
      http://books.dzone.com/articles/spri...let-mvc-part-2

      I hope it could helps you some.

      Comment

      Working...
      X