I don't know WHERE the Oracle team came up with my username (mine was TheWhiteKnight), but it's funny guys.... Thanks for the laugh.
ANYwho....
I have a question. I currently am creating some objects with getter and setter methods. For example, I have created a Department object that has 4 protected static variables that coincide with the database fields for the department table in a database. I have a getter and setter method for each variable, as well as a loader, saver, updater, and validator methods. I have the object auto-validate it's info before setting the variable's. Here is the code:
(what happened to our
tag?)
public class Department {
static final Logger Dept4j = Logger.getLogger(Department.class);
/**
* Each variable name lines up with the database fields.
* Database Table - Departments
*/
protected static int DEPARTMENT_ID;
protected static String DEPARTMENT_NAME;
protected static int PARENT_DEPARTMENT_ID;
protected static boolean STATUS;
public static String validationErrorMessage;
public Department() {
super();
}
public int getDepartmentId() {
return DEPARTMENT_ID;
}
public static void setDepartmentId(int deptId) {
if (validateAllDepartmentIdFields(deptId))
DEPARTMENT_ID = deptId;
}
public String getDepartmentName(){
return DEPARTMENT_NAME;
}
public static void setDepartmentName(String deptName) {
if(validateDepartmentName(deptName))
DEPARTMENT_NAME = deptName;
}
public int getParentDepartmentId() {
return PARENT_DEPARTMENT_ID;
}
public static void setParentDepartmentId(int deptParentId) {
if (validateAllDepartmentIdFields(deptParentId))
PARENT_DEPARTMENT_ID = deptParentId;
}
public boolean getDepartmentStatus() {
return STATUS;
}
public static void setDepartmentStatus(boolean deptStatus) {
if (validateDepartmentStatus(deptStatus))
STATUS = deptStatus;
}
.
.
.
.
Simple enough concept. I'll not post the rest of the class as it's not relevant. I want to be able to write a generic servlet to be able to pass all objects to (Department, User, Occupation, etc) and be able to get and set info from an HTML page reusing the same servlet to show all of the public get / set methods that I open up. What I DON'T want to do is pass resultsets around grabbing metadata and use <% %> scriptlet tags in the front end. I could go the custom route of writing my own tags and passing everything that way, but I'd like a different way to do this. I'm wondering if there is any realistic way I can call a generic sort of "get all getters / setters" and populate a page of DDL's / fields with that. I think I already have the answer, but I'd like to hear it from someone else to confirm it. BTW, I'm using Tomcat 6.0.18 - 6.0.2x for this. Not sure if it actually matters.
Any insight is greatly appreciated. And as always constructive criticism is always welcomed.
- Josh