wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Create GUI from and saving stuff to XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Create GUI from and saving stuff to XML" Watch "Create GUI from and saving stuff to XML" New topic
Author

Create GUI from and saving stuff to XML

Yash Sharma
Ranch Hand

Joined: Jan 30, 2003
Posts: 61
I am confused about the approach I should take on this.

I am using XML as my data-model. A web-based GUI would prepare the GUI from this XML. Let's say this is a Book XML where using the GUI user could (1) select his preferred chapter and (2) Save this choice. To generate the GUI and saving user's preference I plan to use the same XML (say master.xml).

The XML:


The GUI can certainly be made from this, a drop down containing all the chapter titles and a button to save the preference. When the user saves it, the XML would be saved (as say user_xyz.xml) and looks like:


So far so good Imagine now that the author adds few more chapters so the XML now becomes:


I see no problem in saving a new preference the GUI dropdown will now display four chapters instead of two. However, what if the user XYZ decides to alter his preference, if my GUI is created using "user_xyz.xml" the GUI is not aware of the additional two chapters now available. If it is created using "master.xml" it has no knowledge of the user's previous preference.

I hope I made myself clear. Should then my approach to creating the GUI be parsing both master and user's XML and then create it, could be taxing if XML is complex and bulky. Or should I update the user's xml every time master changes, again how will I update it. Or is there any other suitable approach?

Thanks for your time.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Your problem stems from the fact that you're mixing two different things with a different lifecycle -- the chapters and the user's preferences. Try separating the two into their own files and then "merging" them where appropriate.

For example:


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
Don't get me started about those stupid light bulbs.
 
subject: Create GUI from and saving stuff to XML
 
Similar Threads
how can i parse?
Is It bug in web start?
Web app security
Xml Conversion
Unicode Char Problem