aspose file tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes dynamically add a new filed ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Reply Bookmark "dynamically add a new filed ?" Watch "dynamically add a new filed ?" New topic
Author

dynamically add a new filed ?

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 758
Let say, we have a event management product for an user. One feature is, user could self-define new field to accommodate his own need, for example, he could add "do I take morning exercise today? Yes Or No " checkbox to the system, afer this, the new field will show up on the screen and its column is added to database without restart

How to design this system ? what technology is good ?

Usually we will define POJO class and mapped to database and show them on the screen. Here problem, if user dynamically add a new filed, we can't modify POJO in the runtime.
This is a challenge.

Thanks.
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
You can use JDBC, and keep schema in XML.
For dynamic schema, you cannot use "hard-coded" classes, you need to have generic ones, like EntityData, EntityType.

Try to think about what methods EntityData and EntityType should have.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Take a look at http://martinfowler.com/apsupp/properties.pdf to get some inspiration.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 758
Ilja Preuss wrote:Take a look at http://martinfowler.com/apsupp/properties.pdf to get some inspiration.


Thanks. I have some idea how to achieve this.

I can define object properties in xml, user could add / delete property from xml file. Then I write a JDBC generator converting xml to JDBC. This should be work.

Then another problem arises. how to define it in JSP page ? what is sequence ? do I need to define a sequence number in XML file ? or we have another options ?

Thanks.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: dynamically add a new filed ?
 
Similar Threads
please help with jsp design
xml api for runtime modification
DTO/VO or a Universal Map
Good uses of Ajax
Refresh problem