1 package org.apache.turbine.util.jsp; 2 3 18 19 import java.lang.reflect.Method ; 20 import java.util.Enumeration ; 21 import org.apache.turbine.modules.ActionEvent; 22 import org.apache.turbine.services.jsp.TurbineJsp; 23 import org.apache.turbine.util.ParameterParser; 24 import org.apache.turbine.util.RunData; 25 import org.apache.velocity.context.Context; 26 27 45 public abstract class JspActionEvent extends ActionEvent 46 { 47 54 public abstract void doPerform(RunData data) 55 throws Exception ; 56 57 65 protected void perform(RunData data) 66 throws Exception 67 { 68 try 69 { 70 executeEvents(data, TurbineJsp.getContext(data)); 71 } 72 catch (NoSuchMethodException e) 73 { 74 doPerform(data); 75 } 76 } 77 78 85 public void executeEvents(RunData data, Context context) throws Exception 86 { 87 String theButton = null; 89 90 ParameterParser pp = data.getParameters(); 92 93 String button = pp.convert(BUTTON); 94 95 for (Enumeration e = pp.keys() ; e.hasMoreElements() ;) 97 { 98 String key = (String ) e.nextElement(); 99 if (key.startsWith(button)) 100 { 101 theButton = formatString(key); 102 break; 103 } 104 } 105 106 if (theButton == null) 107 throw new NoSuchMethodException ("ActionEvent: The button was null"); 108 109 try 110 { 111 Class [] classes = new Class [2]; 113 classes[0] = RunData.class; 114 classes[1] = Context.class; 115 116 Object [] args = new Object [2]; 118 119 Method method = getClass().getMethod(theButton, classes); 120 args[0] = data; 121 args[1] = context; 122 method.invoke(this, args); 123 } 124 catch (NoSuchMethodException nsme) 125 { 126 super.executeEvents(data); 128 } 129 } 130 } 131 132 133 134 | Popular Tags |