1 package org.jahia.clipbuilder.html.struts.Util; 2 3 import org.apache.struts.action.*; 4 import javax.servlet.http.*; 5 import java.lang.reflect.*; 6 import org.jahia.clipbuilder.html.bean.*; 7 8 13 public abstract class AbstractWizardForm extends ActionForm { 14 15 private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(AbstractWizardForm.class); 16 17 18 21 public void setAllPropertiesToNull() { 22 try { 23 Method[] methods = getClass().getMethods(); 25 for (int i = 0; i < methods.length; i++) { 26 Method m = methods[i]; 27 Class declarationClass = m.getDeclaringClass(); 28 if (declarationClass.equals(getClass())) { 30 String label = m.getName(); 31 logger.debug("[ Method " + label + " is in process. ]"); 32 if (label.substring(0, 3).equalsIgnoreCase("set")) { 34 String methodToCall = "set" + label.substring(3); 36 String [] values = {null}; 37 Class [] paramType = {String .class}; 38 this.getClass().getMethod(methodToCall, paramType).invoke((Object )this, (Object [])values); 39 } 40 } 41 } 42 43 } 44 catch (NoSuchMethodException ex) { 45 logger.error(" [ Error " + ex.toString() + " ] "); 46 ex.printStackTrace(); 47 } 48 catch (InvocationTargetException ex) { 49 logger.error(" [ Error " + ex.toString() + " ] "); 50 ex.printStackTrace(); 51 } 52 catch (IllegalArgumentException ex) { 53 logger.error(" [ Error " + ex.toString() + " ] "); 54 ex.printStackTrace(); 55 } 56 catch (IllegalAccessException ex) { 57 logger.error(" [ Error " + ex.getMessage() + " ] "); 58 ex.printStackTrace(); 59 } 60 catch (SecurityException ex) { 61 logger.error(" [ Error " + ex.getMessage() + " ] "); 62 ex.printStackTrace(); 63 } 64 } 65 66 67 72 public abstract int getId(); 73 74 75 80 public int getNextFormId() { 81 int id = this.getId(); 82 if (id < Constants.MANAGE || id > Constants.PREVIEW) { 83 return -1; 84 } 85 86 return id + 1; 87 } 88 89 90 95 public abstract void loadFromClipperBean(ClipperBean cBean); 96 97 } 98 | Popular Tags |