1 24 package org.riotfamily.riot.list.command.core; 25 26 import org.riotfamily.riot.editor.EditorDefinition; 27 import org.riotfamily.riot.list.command.CommandContext; 28 import org.riotfamily.riot.list.command.CommandResult; 29 import org.riotfamily.riot.list.command.result.GotoUrlResult; 30 import org.springframework.util.Assert; 31 32 33 36 public class EditCommand extends AbstractCommand { 37 38 public static final String ACTION_EDIT = "edit"; 39 40 public static final String ACTION_ADD = "add"; 41 42 protected String getAction(CommandContext context) { 43 return context.getBean() != null ? ACTION_EDIT : ACTION_ADD; 44 } 45 46 public CommandResult execute(CommandContext context) { 47 EditorDefinition def = context.getListDefinition().getDisplayDefinition(); 48 Assert.notNull(def, "A DisplayDefinition must be set in order to use the EditCommand."); 49 return new GotoUrlResult(context, def.getEditorUrl( 50 context.getObjectId(), context.getParentId())); 51 } 52 } 53 | Popular Tags |