Question

I am having some doubt regarding Spring MVC Portlet Controller.

I would like to define a controller, which will paint the portlet for the first time, any subsequent actions from the portlet will trigger respective action methods

@Controller("searchController")
@RequestMapping("VIEW")
public class SearchController {

    @RenderMapping
    public String showSearch(RenderRequest request, Locale locale, Model model) {
        logger.info("Loading the Search Bar");
        return "search";
    }


     @ActionMapping("")  //default action that should be executed for first time
    public void fetchSearchDetails(ActionRequest request, ActionResponse response, SessionStatus sessionStatus) {
        logger.info("Searching the Refinement"); 
    }

    @ActionMapping("searchAction")
    public void searchProduct(@Valid @ModelAttribute(value = "product") Product product, BindingResult bindingResult,
            ActionRequest request, ActionResponse response, SessionStatus sessionStatus) {
        //execute if actionURL is searchAction
    }

}

How do I declare/call default Action method if the portlet is getting loaded for the first time or no action.

Was it helpful?

Solution

Try putting @ActionMapping rather than @ActionMapping("").

OTHER TIPS

The first time the portlet is displayed, only the render phase is executed, not the action phase. So I guess you should take care of your default behavior in the render phase, and remove your default action method (fetchSearchDetails).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top