Reputation:
I'm trying to integrate SpringMVC with Liferay, up until now I have had mixed success, but this particular issue is driving me crazy. I have this very crude Controller
@Controller
@RequestMapping(value = "VIEW")
public class AppointmentsController {
@RequestMapping
public ModelAndView showAppointments(RenderRequest request, RenderResponse response) {
return new ModelAndView("view");
}
@RequestMapping(params={"action=addAppointment"}) // render phase
public String showAddAppointmentsForm(Model model) {
//return new ModelAndView("add_appointment");
System.out.println("TEST");
return "add_appointment";
}
}
The very first mapping, works fine, the portlet that this controller is responsible for renders flawlessly. In the jsp file that contains the view of the portlet, I have this
<aui:button-row>
<portlet:actionURL var="addAppointmentURL">
<portlet:param name="action" value="addAppointment" />
</portlet:actionURL>
<aui:button onClick="${addAppointmentURL}" value="Add New Appointment" />
<aui:button type="button" value="Appointment History" />
</aui:button-row>
Now, the problem is that when I click on the "Add New Appointment" button, the action request doesn't get processed by showAddAppointmentsForm in the controller, instead I get
org.springframework.web.portlet.NoHandlerFoundException: No matching handler method found for portlet request: mode 'view', p hase 'ACTION_PHASE', parameters map['action' -> array<String>['addAppointment']]
I have tried lots of stuff, changed the portlet mode from VIEW to EDIT - didn't work, changed @RequestMapping of the showAddAppointmentsForm method to @ActionMapping - that work, but it insists that the decorated method should be void ergo I can't return the new jsp file that I want rendered.
I have referenced the documentation here -> http://docs.spring.io/spring/docs/4.1.x/spring-framework-reference/html/portlet.html#portlet-ann-requestmapping-arguments but as far as I can see I'm doing the same things.
It's driving me crazy, am I missing something?
Upvotes: 2
Views: 1544
Reputation:
So, after the answer of @Danish, I kinda got on track what I did is:
@RenderMapping(params={"action=addAppointment"}) // render phase
public String showAddAppointmentsForm(Model model) {
//return new ModelAndView("add_appointment");
System.out.println("TEST");
return "add_appointment";
}
Notice the @RenderMapping anotation, not @RequestMapping or @ActionMapping.
In the view:
<portlet:renderURL var="addAppointmentURL">
<portlet:param name="action" value="addAppointment"></portlet:param>
</portlet:renderURL>
<aui:button onClick="${addAppointmentURL}" value="Add New Appointment" />
Upvotes: 2
Reputation: 913
try this @ActionMapping(params = "action=addAppointment")
More info here http://www.opensource-techblog.com/2012/09/render-and-action-methods-in-spring-mvc.html
Upvotes: 2