简体   繁体   中英

Defining default Portlet Action method

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.

尝试放置@ActionMapping而不是@ActionMapping("").

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM