| 1 24 package org.riotfamily.components.editor; 25 26 import javax.servlet.http.HttpServletRequest ; 27 28 import org.riotfamily.forms.factory.FormRepository; 29 import org.riotfamily.riot.dao.RiotDao; 30 import org.riotfamily.riot.list.ListRepository; 31 32 38 public class EntityFormController extends AbstractComponentFormController { 39 40 private String listIdAttribute = "listId"; 41 42 private String objectIdAttribute = "objectId"; 43 44 private ListRepository listRepository; 45 46 public EntityFormController(FormRepository formRepository, 47 ListRepository listRepository) { 48 49 super(formRepository); 50 this.listRepository = listRepository; 51 } 52 53 protected RiotDao getDao(HttpServletRequest request) { 54 String listId = (String ) request.getAttribute(listIdAttribute); 55 return listRepository.getListConfig(listId).getDao(); 56 } 57 58 protected Object getFormBackingObject(HttpServletRequest request) { 59 String objectId = (String ) request.getAttribute(objectIdAttribute); 60 return getDao(request).load(objectId); 61 } 62 63 protected void onSave(Object entity, HttpServletRequest request) { 64 getDao(request).update(entity); 65 } 66 67 } | Popular Tags |