org.springframework.samples.petportal.portlet
Class PetsController

java.lang.Object
  extended by org.springframework.samples.petportal.portlet.PetsController

@Controller
@RequestMapping(value="VIEW")
@SessionAttributes(value="pet")
public class PetsController
extends java.lang.Object

This is a simple Controller which delegates to the PetService and then populates the model with all returned Pets. This could have extended AbstractController in which case only the render phase would have required handling. However, this demonstrates the ability to simply implement the Controller interface.

Author:
John A. Lewis, Mark Fisher, Juergen Hoeller

Constructor Summary
PetsController(PetService petService)
           
 
Method Summary
 void deletePet(int petId, javax.portlet.ActionResponse response)
           
protected  java.lang.String getDateFormat(javax.portlet.PortletPreferences preferences)
          For the page where the 'birthdate' is to be entered, the dateFormat is provided so that it may be displayed to the user.
 void initBinder(org.springframework.web.portlet.bind.PortletRequestDataBinder binder, javax.portlet.PortletPreferences preferences)
          Registers a PropertyEditor with the data binder for handling Dates using the format as currently specified in the PortletPreferences.
 java.lang.String listPets(org.springframework.ui.Model model)
           
 java.lang.String showPetForm(org.springframework.ui.Model model)
           
 void submitPage(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response, Pet pet, org.springframework.validation.BindingResult result, int currentPage, org.springframework.ui.Model model)
           
 java.lang.String viewPet(int petId, org.springframework.ui.Model model)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PetsController

public PetsController(PetService petService)
Method Detail

getDateFormat

@ModelAttribute(value="dateFormat")
protected java.lang.String getDateFormat(javax.portlet.PortletPreferences preferences)
For the page where the 'birthdate' is to be entered, the dateFormat is provided so that it may be displayed to the user. The format is retrieved from the PortletPreferences.


initBinder

@InitBinder
public void initBinder(org.springframework.web.portlet.bind.PortletRequestDataBinder binder,
                                  javax.portlet.PortletPreferences preferences)
Registers a PropertyEditor with the data binder for handling Dates using the format as currently specified in the PortletPreferences.


listPets

@RequestMapping
public java.lang.String listPets(org.springframework.ui.Model model)

viewPet

@RequestMapping(params="action=view")
public java.lang.String viewPet(@RequestParam(value="pet")
                                               int petId,
                                               org.springframework.ui.Model model)

showPetForm

@RequestMapping(params="action=add")
public java.lang.String showPetForm(org.springframework.ui.Model model)

submitPage

@RequestMapping(params="action=add")
public void submitPage(javax.portlet.ActionRequest request,
                                      javax.portlet.ActionResponse response,
                                      @ModelAttribute(value="pet")
                                      Pet pet,
                                      org.springframework.validation.BindingResult result,
                                      @RequestParam(value="_page")
                                      int currentPage,
                                      org.springframework.ui.Model model)

deletePet

@RequestMapping(params="action=delete")
public void deletePet(@RequestParam(value="pet")
                                     int petId,
                                     javax.portlet.ActionResponse response)


John A. Lewis, Mark Fisher, Juergen Hoeller - 2007.