Results 1 to 3 of 3

Thread: Methods not being called in a Spring MVC Portlet Form

  1. #1
    Join Date
    Nov 2011
    Posts
    1

    Question 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. #2
    Join Date
    Jan 2012
    Posts
    1

    Default

    Hello,

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

    Thanks in advance.
    MC

  3. #3
    Join Date
    Dec 2011
    Posts
    11

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •