EditMealForm.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* ===================================================================
  2. * EditMealForm.java
  3. *
  4. * Created Oct 12, 2004 9:45:49 AM
  5. *
  6. * Copyright (c) 2004 Matt Magoffin (spamsqr@msqr.us)
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  21. * 02111-1307 USA
  22. * ===================================================================
  23. * $Id: EditMealForm.java 28 2009-05-04 01:19:45Z msqr $
  24. * ===================================================================
  25. */
  26. package magoffin.matt.ieat.web;
  27. import javax.servlet.http.HttpServletRequest;
  28. import org.springframework.web.bind.ServletRequestDataBinder;
  29. import magoffin.matt.ieat.biz.BizContext;
  30. import magoffin.matt.ieat.domain.Meal;
  31. import magoffin.matt.ieat.domain.UiEdit;
  32. import magoffin.matt.ieat.util.MealCommand;
  33. /**
  34. * Form controller for editing an existing meal.
  35. *
  36. * @author Matt Magoffin (spamsqr@msqr.us)
  37. * @version $Revision: 28 $ $Date: 2009-05-04 13:19:45 +1200 (Mon, 04 May 2009) $
  38. */
  39. public class EditMealForm extends AddMealForm {
  40. @Override
  41. protected Object formBackingObject(HttpServletRequest request)
  42. throws Exception
  43. {
  44. // get the meal ID to edit
  45. MealCommand mc = new MealCommand();
  46. ServletRequestDataBinder binder = createBinder(request, mc);
  47. binder.bind(request);
  48. BizContext context = WebUtil.getBizContext(request, false);
  49. Meal meal = recipeBiz.getMealById(mc.getMealId(),context);
  50. UiEdit edit = getDomainObjectFactory().getUiEditInstance();
  51. edit.setMeal(meal);
  52. return edit;
  53. }
  54. }