KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > clipbuilder > html > struts > Util > AbstractWizardForm


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 /**
9  * Description of the Class
10  *
11  *@author Tlili Khaled
12  */

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     /**
19      * Sets the AllPropertiesToNull attribute of the ClipperForm object
20      */

21     public void setAllPropertiesToNull() {
22         try {
23             // test if the source and the target has same class
24
Method[] methods = getClass().getMethods();
25             for (int i = 0; i < methods.length; i++) {
26                 Method m = methods[i];
27                 Class JavaDoc declarationClass = m.getDeclaringClass();
28                 // don't process method in the super classes
29
if (declarationClass.equals(getClass())) {
30                     String JavaDoc label = m.getName();
31                     logger.debug("[ Method " + label + " is in process. ]");
32                     // process only the get method
33
if (label.substring(0, 3).equalsIgnoreCase("set")) {
34                         //execute the setMethod on the target form
35
String JavaDoc methodToCall = "set" + label.substring(3);
36                         String JavaDoc[] values = {null};
37                         Class JavaDoc[] paramType = {String JavaDoc.class};
38                         this.getClass().getMethod(methodToCall, paramType).invoke((Object JavaDoc)this, (Object JavaDoc[])values);
39                     }
40                 }
41             }
42
43         }
44         catch (NoSuchMethodException JavaDoc 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 JavaDoc ex) {
53             logger.error(" [ Error " + ex.toString() + " ] ");
54             ex.printStackTrace();
55         }
56         catch (IllegalAccessException JavaDoc ex) {
57             logger.error(" [ Error " + ex.getMessage() + " ] ");
58             ex.printStackTrace();
59         }
60         catch (SecurityException JavaDoc ex) {
61             logger.error(" [ Error " + ex.getMessage() + " ] ");
62             ex.printStackTrace();
63         }
64     }
65
66
67     /**
68      * Gets the Id attribute of the ClipperAction object
69      *
70      *@return The Id value or -1 if not found
71      */

72     public abstract int getId();
73
74
75     /**
76      * Gets the NextFormId attribute of the ClipperForm object
77      *
78      *@return The NextFormId value
79      */

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     /**
91      * Description of the Method
92      *
93      *@param cBean Description of Parameter
94      */

95     public abstract void loadFromClipperBean(ClipperBean cBean);
96
97 }
98
Popular Tags