1 16 package org.apache.cocoon.forms.formmodel; 17 18 import java.util.Iterator ; 19 20 import org.apache.cocoon.forms.event.ActionListener; 21 import org.apache.cocoon.forms.util.DomHelper; 22 import org.apache.cocoon.util.Deprecation; 23 import org.w3c.dom.Element ; 24 25 30 public class ActionDefinitionBuilder extends AbstractWidgetDefinitionBuilder { 31 32 public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception { 33 ActionDefinition definition = new ActionDefinition(); 34 setupDefinition(widgetElement, definition); 35 definition.makeImmutable(); 36 return definition; 37 } 38 39 protected void setupDefinition(Element widgetElement, ActionDefinition definition) throws Exception { 40 super.setupDefinition(widgetElement, definition); 41 42 setDisplayData(widgetElement, definition); 43 44 String actionCommand = DomHelper.getAttribute(widgetElement, "command", null); 46 47 if (actionCommand == null) { 49 actionCommand = DomHelper.getAttribute(widgetElement, "action-command", null); 50 if (actionCommand != null) { 51 Deprecation.logger.info("The 'action-command' attribute is deprecated and replaced by 'command', at " + 52 DomHelper.getLocation(widgetElement)); 53 } 54 } 55 56 definition.setActionCommand(actionCommand); 57 58 Iterator iter = buildEventListeners(widgetElement, "on-action", ActionListener.class).iterator(); 59 while (iter.hasNext()) { 60 definition.addActionListener((ActionListener)iter.next()); 61 } 62 } 63 } 64 | Popular Tags |