• Post Reply Bookmark Topic Watch Topic
  • New Topic

Seeking programming techniques and guidance...  RSS feed

 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
Following is my requirement, it is similar to asking a user to confirm a list of things he wishes to buy on the Net:
Step (1) User logs in;
Step (2) Selects various sandwiches, what they like to have on it and quantities;
Step (3) User selects other products e.g. drinks, pasta dishes etc
Step (4) Steps 2 and 3 can be repeated again for different products e.g. pasta and ceasar salat (pasta and salats have different JFrames);
Step (5) On clicking the review button, the user is taken to the confirmation screen where the user can view all the items he has selected, along with quantities and price.
Step (6) On clicking JButton confirm, the order is placed.
I've used a series of JFrames, passing parameters from one to the other. At the end of the chain in the confirmaton JFrame.
This is my question: how to I pass the selected items from multiple JFrames e.g. from the sandwich JFrame, the pasta JFrame and the drinks JFrame to the last JFrame containing the list of items and quantities the user has selected?
I've no problems passing parameters from one JFrame to the next, but from many JFrame to one?
Should I be using a background helper class with an array declared public static final and add the items from the other JFrames?
Any hints, tips, links and suggestions appreciated.
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm no expert but I think your are now thinking along the right lines. You need to take the logic code out of the JFrame classes and have a helper class/classes to store and control the state of the users order. If it was me I would make each JFrame effectively 'dumb', so that all it does is pass a simple object or series of parameters with it's state back to the helper classes to sort and store in the main Order object. At the end you can retrieve the entire order from the helper and display it.
This comes down to the Model - View - Controller architecture. I think you need a Model to store the state of the order (this is maybe a helper class called Order), the JFrames will be the View, the Controller will initialise the application and handle the program flow through the frames etc and maybe hold an instance of the Order class for you to work with. HTH
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the advice and your time. :-)
That has given me something to think about before finalizing the architecture.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!