Forums Register Login

Seeking programming techniques and guidance...

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Thanks for the advice and your time. :-)
That has given me something to think about before finalizing the architecture.
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 795 times.
Similar Threads
moving values from 1 select box to another
Answers to IBM 486 sample test
HashMap problem
adding a SelectItem object at particular index position in java.util.list
change Itinerary
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:28:35.