1 16 package org.apache.cocoon.woody.formmodel; 17 18 import java.util.Iterator ; 19 20 import org.apache.cocoon.woody.event.ActionListener; 21 import org.apache.cocoon.woody.util.DomHelper; 22 import org.w3c.dom.Element ; 23 24 29 public class RowActionDefinitionBuilder extends AbstractWidgetDefinitionBuilder { 30 31 32 public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception { 33 String actionCommand = DomHelper.getAttribute(widgetElement, "action-command"); 34 RowActionDefinition definition = createDefinition(widgetElement, actionCommand); 35 setLocation(widgetElement, definition); 36 setId(widgetElement, definition); 37 setDisplayData(widgetElement, definition); 38 39 definition.setActionCommand(actionCommand); 40 41 Iterator iter = buildEventListeners(widgetElement, "on-activate", ActionListener.class).iterator(); 42 while (iter.hasNext()) { 43 definition.addActionListener((ActionListener)iter.next()); 44 } 45 46 return definition; 47 } 48 49 protected RowActionDefinition createDefinition(Element element, String actionCommand) throws Exception { 50 51 if ("delete".equals(actionCommand)) { 52 return new RowActionDefinition.DeleteRowDefinition(); 53 54 } else if ("add-after".equals(actionCommand)) { 55 return new RowActionDefinition.AddAfterDefinition(); 56 57 } else if ("move-up".equals(actionCommand)) { 58 return new RowActionDefinition.MoveUpDefinition(); 59 60 } else if ("move-down".equals(actionCommand)) { 61 return new RowActionDefinition.MoveDownDefinition(); 62 63 } else { 64 throw new Exception ("Unknown repeater row action '" + actionCommand + "' at " + DomHelper.getLineLocation(element)); 65 } 66 } 67 } 68 69 | Popular Tags |