File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Best way to do this... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Best way to do this..." Watch "Best way to do this..." New topic
Author

Best way to do this...

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I really don't know if this is the best forum for this question but I couldn't think of any better place and since I am doing this in a Servlet....


Anyway, when I create a new Issue I have a field called status which is of a type IssueStatus. IssueStatus has 2 fields; id(Integer) and status(String). I have a database table (t_issue_status) with all the possible status' (Open, In Progress, Resolved).

My problem is simply the best way to do the following. When I click submit to create a new Issue, I need to set the Issue objects IssueStatus to Open. This is static as in every time a new Issue is created the status is Open. So I could do something like:



My main problem with this approach is maintence. What if down the road I wanted to change Open to something else. I don't want to have to dig back in the code. So my options are always pull this from the database, use some sort of properies file and load this file in a ContextListener, a combination of the 2. Use my Constants class and provide a public static final Integer OPEN_STATUS = 0.

Any suggestions?


GenRocket - Experts at Building Test Data
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Well, I have two suggestions.

1. A default value in the database. Where you don't have to provide anything since it will automatically be used when a new record is created.

2. JavaScript, have it add it in the client side.

3. Properties file that the Servlet( er helper class) reads to see the default, then you only have to change the properties file when it changes rather than code and recompiling and deploying.

I prefer the first, since there is no code, just db table structure.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Mark Spritzler:
Well, I have two suggestions.

1. A default value in the database. Where you don't have to provide anything since it will automatically be used when a new record is created.

2. JavaScript, have it add it in the client side.

3. Properties file that the Servlet( er helper class) reads to see the default, then you only have to change the properties file when it changes rather than code and recompiling and deploying.

I prefer the first, since there is no code, just db table structure.

Mark


I like option #1 as well. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best way to do this...