FileDocCategorySizeDatePackage
SignonController.javaAPI DocExample1673Thu Dec 04 08:19:26 GMT 2003org.springframework.samples.jpetstore.web.spring

SignonController

public class SignonController extends Object implements org.springframework.web.servlet.mvc.Controller
author
Juergen Hoeller
since
30.11.2003

Fields Summary
private org.springframework.samples.jpetstore.domain.logic.PetStoreFacade
petStore
Constructors Summary
Methods Summary
public org.springframework.web.servlet.ModelAndViewhandleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

		String username = request.getParameter("username");
		String password = request.getParameter("password");
		Account account = this.petStore.getAccount(username, password);
		if (account == null) {
			return new ModelAndView("Error", "message", "Invalid username or password.  Signon failed.");
		}
		else {
			UserSession userSession = new UserSession(account);
			PagedListHolder myList = new PagedListHolder(this.petStore.getProductListByCategory(account.getFavouriteCategoryId()));
			myList.setPageSize(4);
			userSession.setMyList(myList);
			request.getSession().setAttribute("userSession", userSession);
			String forwardAction = request.getParameter("forwardAction");
			if (forwardAction != null) {
				response.sendRedirect(forwardAction);
				return null;
			}
			else {
				return new ModelAndView("index");
			}
		}
	
public voidsetPetStore(org.springframework.samples.jpetstore.domain.logic.PetStoreFacade petStore)

		this.petStore = petStore;