Making middle teir accessible to all gui class objects.

I'm designing a user interface at the moment for a
3 tier application. I've got a good knowledge of Java
but have never written a complicated gui with Swing.....
User Interface (GUI) --> Business Logic (JDBC classes) --> MYSQL DB
As the diagram shows, I want to keep the business logic separate
from the user interface.
My problem is that I'm not sure the best way to give all the GUI's action listeners
access to the business logic object's methods which will call and return information
from the database to the UI.
Had there just been one UI class it would be easy to create an instance of the
business logic class from the UI class, but
the GUI is made up of many class objects with larger componets being made
up of several smaller component classes and so on. What I guess I'm unsure of
is what the standard practice is in this situation. Is a case of getting the GUI creation class
to create an instance of the business logic object and then pass it down through the many
GUI class constructors so that each GUI class object can reference it?
You thoughts are appreciated, many thanks,
Andrew.

The commom practice here is to use some design patterns.
The ones you need are Proxy and DTO (Data Transfer Object).
The reasons behind using a proxy patters are that your DB could
change location, and you could have multiple GUI's using the
same DB
You will have several DTO's which will contain the data from your
database. These DTO's are used to group data common to one use
case, so that in order to complete the use case, you only need to
remotely access the DB once. These Dto's are regular Java objects
with just getter and setter methods.
Your GUI uses a Proxy object to request a DTO.
someting like... you need some data to fill a form or a table?
GUIProxy proxy = ProxyServices.getGUIProxy();
FormDataDto dto = proxy.getFormData();
JTexField nameField = new JTextField();
nameField.setText(dto.getCustomerName());
etc...
Notice how your GUI has no idea where the data lives,
how its stored, etc. It just knows how to request it.

Similar Messages

  • Making a file accessible to all users

    Hi
    Win 8.1 Pro with Media Centre.
    I have a win 8.1 pc connected to a SBS 2011 domain. I have an MS Access MDE file in C:\Folder1\Folder2\Folder3z\MyMDE.MDE. I need the MDE file accessible to all users logged into to the pc. No matter how I set the permissions on the MDE file and the folders
    including Everyone the file is not accessible to all users. I have also disabled the User Account Control but no luck.
    What are simple steps to have a file accessible to all users please?
    Thanks
    Regards

    Hi,
    According to your description, I think this should be the folder problem. However, you can try to copy this file to the root of other Drive for test.
    In addition, please make sure its user was Everyone and had full control like screenshot below:
    Roger Lu
    TechNet Community Support

  • Importing Class Objects created in IFS Manager into a JSP page

    I create a class object using IFS Manager which consisted of extended attributes. I hope this is the right thing to do when I want to manage some extra attributes of a DOCUMENT. But the question is what package do I import to access this newly create Class Object

    Thank you. The information was very helpful.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Joyce Peng:
    I believe you created a subclass of Document using iFS manager.
    Your new subclass is like any other class object in iFS.
    Here is an example of how to access a custom class EXPENSEREPORT with a custom attribute APPROVER.
    //Gets the the collection of all the class objects.
    //Then gets the specific EXPENSEREPORT class object.
    Collection classObjectCollection = session.getClassObjectCollection();
    ClassObject expenseReportClassObject =
    (ClassObject) classObjectCollection.getItems("EXPENSEREPORT");
    //Gets the APPROVER attribute for the class object.
    Attribute attribute = expenseReportClassObject.getEffectiveClassAttributes("APPROVER");
    <HR></BLOCKQUOTE>
    null

  • Listen for events in another Gui class

    Most of the GUIs I have written to date have consisted of either a single class or multiple self-contained classes - mainly extensions of JPanel with JButtons etc to perform certain tasks.
    Now I want to be able to click a JButton in one class which will invoke a method in another.
    The code is too lengthy to post here but this is the general layout:
    JFrame Simulation_GUI contains a JPanel (panelMain) which is set as the content pane
    panelMain contains two GUI classes which extend JPanel;
    buttonPane > contains a number of JButtons, including the one I want to click
    loadingPane > contains the method (which takes a Hastable as an argument) I want to run
    All three panels are declared in the main class which extends JFrame, so I know that from there I can simply call;
    loadingPanel.runLoads(htData); but how do I do this from the JButton on the buttonPane.
    Any assistance greatly appreciated as I have little enough hair at the moment and can't afford to tear much more out.
    Thanks in advance

    Class GUI1 {
    //Display all the buttons.
    public void init() {
    Button.addActionListener(new
    ener(new SomeClass(this));
    Class SomeClass implements ActionListener {
    GUI1 gui = null;
    SomeClass(GUI1 gui) {
    this.gui = gui;
    public void actionPerformed(ActionEvent e) {
    //Do all your process here
    gui.setTable(table);    //table would be ur
    ould be ur hashtable
    }Cheers
    -PThis didn't fully answer my question but did two things:
    1. Told me that it is at least possible and it is just me having a senior moment,
    2. Sent me on the right road to finding a solution
    With additional help from the following post I have sorted my problem. Basically I had to centrallise the event handling into a different class. This was instantiated by the main GUI class and passed to the other GUI components as an argument.
    http://forum.java.sun.com/thread.jspa?threadID=576012&messageID=2881969
    Simple when you know how...!
    prashanth_kuppur - have some Duke Dollars on me and thanks for the poke in the right direction.

  • Trying to pass parameters between GUI classes and methods

    Hi All.
    I have been working on a rather large final year project in college and it is getting close to the deadline. It looks as though I need to "tidy up" my code as it contains too many static methods, variables and other bad programming habits. My package consists of many different GUI's and classes. Up until now I have been calling different GUI's with guiName.NameOfMethod. I have been told this is bad practice so I am trying to fix this. Also instead of passing parameters correctly I have been creating static variables in my main class and using them. So for example if one class needed to pass a variable to the other I would first myGlobalVariable = X; in the first class. And then the second class can use this. This is also bad, right?
    So I guess im really just looking for a good example or tutorial on how to pass parameters between classes and methods, GUI if possible. Here is an example of how my GUI classes look:
    public class anotherGUI extends JFrame implements ActionListener {
            private JTextField a, b, c;
            private JButton button1, button2;
            JPanel p, p1;                   
            public anotherGUI() {
                LayOutAnotherGUI();
                setLocationRelativeTo(DnDMain.pictureArray[a]);
                setTitle("Example");
                setVisible(true);
                pack();     
            private void LayOutAnotherGUI(int c) {
         //GUI is layed out here     
            public void actionPerformed(ActionEvent e) {
                Object source = e.getSource();
                if (source == submit)
                    clickOK();
            public void clickOK(){
                //Here is where I have been accessing and modifying static global variables.  (But this needs to change).
    public void showanotherGUI() {
            new anotherGUI();
    }This is more or less how I have been going about creating my GUI's. These are used as pop ups. The user enters a value and then it is closed.
    To be honest I have been able to pass a variable correctly from one class to a GUI class but I have still having difficulty. For example in my code above I can pass the variable into this class but I cannot pass it into clickOK(). An this is where it is needed.
    Can anyone please help?
    I hope I have explained my problem well.
    Thanks in advance.

    I dont think that is what I need. An example of what I do in my program is:
    I have a main GUI with an array of images. There are a number of other small GUI's that appear for certain functions when the user clicks on an image or does some other function. I am trying to pass a value into the GUI class that is used for the smaller "pop up" GUI. So lets say the user has clicked the image in array[12]. Then a GUI is displayed. I need to pass the integer 12 into this class.
    Thanks.

  • Updating multiple GUI classes

    Hi,
    I'm wondering how it would be possible to have a class (class1) used for information, then two new classes (class2, class3) both used to display the same information from class1 in two seperate ways.
    So far I've put a variable in class2 and again in class3 that can be initialised to class1 at construction, so then all I do is just use class1's get() methods to get the information to display in class2 and class3.
    The problem is, I'm not sure how to make class2 and class3 update themselves every time the information in class1 changes.

    The GUI classes should register with the data class as change listeners. You'd typically create your own subclass of EventListener and EventObject. Add addXXXListner(), removeXXXListener and fireXXXListener methods to the data object. When the data changes the data objects first all the registered listeners, which can then query the new data in the normal way.

  • Adding all dependent classes of an applet to make a jar file

    Hi everyone,
    I have this problem which I was not able to find a solution for, So I truly appreciate any feedback on this.
    I have a project on eclipse which is basically an applet.
    This applet is using some classes in some jars that I have imported as libraries for this project.
    Everything works on eclipse with no problem. However I need to make a jar file of the applet and required classes to use it in an html page.
    Now that's the part I have been facing difficulties, cuz I have to include all the classes that the applet is using from other jar
    files. And I can not come up with a way to find out all those classes.
    On the other side if I include the whole jars then my applet goes over 100 meg and would be useless.
    I am going to give an example of the problem I have in hope of making it a bit clear.
    I have a applet, which uses some classes from some jars. i.e., class A. but class A itself need class B and etc.
    Now how can I find all these dependencies since I have to include them along the applet in the jar file I am going to make.
    Once again I appreciate any feedback and sorry that is a long question.

    Fractalz wrote:
    . . . Now that's the part I have been facing difficulties, cuz I have to include all the classes that the applet is using from other jar
    files. And I can not come up with a way to find out all those classes.See the Class-Path: parameter (of a Manifest file) documentation here:
    http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#Manifest-Overview

  • Java GUI classes

    Hi,
    I created a simple aplication to store student data in a database.Got a set of classes like student.java subject.java teacher.java
    ,and another set of clases that produce the GUI screen.
    My question is,are the classes created for the GUI screen,included in the CLASS DIAGRAM?
    Would be good if some-one helps on this.
    Rahul

    The short answer to that is that there is no such thing as "the CLASS DIAGRAM". Imagine an application with hundreds of classes; a diagram drawn with all the classes and their relationships would be unreadable. When I want to draw a class diagram I start with the caption -- all good diagrams, not matter what kind, have a caption, right? Given your caption, only include the classes and relationships that are relevant to the caption. When you think of the problem from that angle, it becomes trivial.

  • My ipod classic has started making a mewing sound and all it does is scroll through the songs.  It will not play except when connected to my computer.  I tried resyncing and that did not work. How do I fix this problem?

    My ipod classic has started making a mewling sound and all it does is scroll through the songs.  It does not play on my Bose sound dock or through earbuds.  It will play when connected to the computer...but that makes it hard to take it on a walk with me   I thought it might be a synching problem so tried that--still doesn't work.  How do I fix this problem with out restoring it to the factory setting?  I do not want to lose all my music content as some of it I cannot replace easily.  Please help with suggestions and advice. Thanks.  Karen in GA

    Have you recharge your iPod for at least 2 hours, preferably till the Full charge Battery symbol comes ON.?
    See this Apple support Article
    http://www.apple.com/support/ipod/five_rs/classic/
    You did not by chance bought the Hello Kitty special edition?
    Have nice day!

  • How to connect a Desktop app to a middle teir server app?

    Please tell me if i have posted this in the incorrect forum.
    I currently have a Desktop app that connects directly to a mySQL database. The persistence abilities have been really helpful since our database is still evolving. I have been frustrated by the differences in the SE persistence implementation. I have had to do some hackish things to ensure that the app retrieves the current information. I don't like connecting directly to the database from the desktop app, even though security is not a worry. I have been thinking that the best solution is to have a JEE app running that the desktop app connects to. This also would act as a sort of api for accessing our data, so if and when i create other client desktop apps i don't have to recreate the wheel. From what i gather i will want to run an application server such as tomcat or glassfish. I'm not sure if i understand why though. Since i have control of the server, couldn't i directly open ports for communication to the clients?
    Assuming that there are many ways to pass information between them, advice on the most effective would be nice. I'm guessing serializing objects for passing would be the fastest, but using something like XML, would be a lot easier to monitor.
    Although i have done a lot of reading, i'm still baffled by the EE lingo.
    EJB: kind of like a modular program that facilitates server to server communication?
    JSF: package up stuff for viewing/ running an application through a browser?
    Servlets: Mystifying, which leads me to think that they are what i'm looking for.
    Any advice would be helpful. I'm hoping that there is not some type of restriction in regards to connecting a JSE6 app to a JEE6 app. I basically want to have the best of both worlds.
    Thank you,
    Chip

    Chipper wrote:
    From what i gather i will want to run an application server such as tomcat or glassfish. I'm not sure if i understand why though.If you have a middle teir, you imply that you want frontend and a backend also, the function of the middle teir is to insolate and abstract the backend from the frontend. This is the significant difference from what you have now: client server--frontend and a backend.
    The middle tier, as you have implied, is where you put your access to your backend. And, yes, you are creating an interface to your DB there, wherein you will develop an entire API for accessing your DB. This will give you added security by not letting your clients know anything about your backend.
    Now, how do you access this middle tier? There are several options there, but a few options are:
    1 - Running direct socket communication
    2 - Web Services: code ran on the server to extend the functionality and open services on the middle tier.
    3 - Applets: code ran in the browser on client side to access the server and it's services.
    Assuming that there are many ways to pass information between them, advice on the most effective would be nice. I'm guessing serializing objects for passing would be the fastest, but using something like XML, would be a lot easier to monitor.At this point you are the only one that can answer that question: there are arguments for an against most method that could be picked. Let's take for instance an object that contains 1 usable byte of data. Is it better to serialize the object for that one byte? Send XML to a DB? Or, perhaps, just send the byte of info and synthesize appropriate key information? You have to look at what you are trying to achieve and your requirements.
    Even a scratch of the surface discussion is not possible here, let alone, a howto on implementation for your enterprise. I suggest hitting the tutorials and finding a good book.
    Do you have specific questions? Ones that can be answered in a paragraph or two.

  • How to load all the classes in a JAR file at runtime?

    Any clues o:
    "How can I force JVM to load all the classes in a specified JAR at once?"
    Thanx!
    -Rajeev

    Well I was thinking may be there exists an option with "java", when I
    am starting an application from a jar file, I could force it to load all
    the classes in the JAR. I don't want to do it programically. Is there such
    an option available?? Or in other words can I ask JVM to not do the dynamic
    loading for the JAR??
    Thanx.
    List all JarEntries and convert the paths to fully
    qualified class files
    e.g file in jar
    [1] /com/mycompany/proj/X.class
    should become
    [2] com.mycompany.proj.X
    then for each entry issue
    Class.forName( [2] );

  • Use of swings- one class calling the gui class

    Hi,
    I have a class Manager and a class ManagerGUI.
    My ManagerGUI class looks somehting like this-
    public class ManagerGUI extends JFrame
    String name;
    JPanel namePanel;
    JTextField nameInput;
    JLabel nameLabel;
    Manager empAgent;
    ManagerGUI(Manager ea)
    super(ea.getLocalName());
    empAgent = ea;
    //make the name panel and add it to the topPanel.
    addListeners();
    getContentPane().add(topPanel, BorderLayout.CENTER);
    setResizable(false);
    }//end constructor.
    public void show()
    pack();
    super.setVisible(true);
    void addListeners()
    nameInput.addActionListener(new NameL());
    class NameL implements ActionListener
    public void actionPerformed(ActionEvent e)
    nameE = nameInput.getText();
    }//end class ManagerGUI.
    I have tried to seperate it out so that any changes can be easily implemented (although it perhaps is a long way of doing things).
    Now I have a class Manager that wants to call the GUI and then process the information got from the text field.
    I use the following lines to call the GUI class.
    manGui = new ManagerGUI(this);
    manGui.show();
    Is this the correct way of calling the GUI class?
    How do I get to use the variable nameE here, in the Manager?
    Thanks.

    Hi,
    I have no idea why you want to have an instance of Manager class in class ManagerGUI and an instance of ManagerGUI class in Manager class.
    I will create an instance of Manager in ManagerGUI and show the GUI there.
    In Manager you can create method that will accept the text from textfield in parameter.
    L.P.

  • Possible to store a variable in one comp and accessible to all other comps.

    Hi There,
    This question is mainly for architectural reasons.  Is there a way within the After Effects project file, to declare a global variable that is accessible to all comps?  I want to simply define a variable, set its value, and have that variable accessible to all the comps in the project.  Is there an "order" to which expressions get evaluated first?
    Any pointers or tips are greatly appreciated.
    Thanks!

    Hi Dan,
    Thank you for your time and reply.  I am only trying to get access to a string from any comp.  I never thought about using a Composition object as a container for global variables, but your hint about the slider made me think of that.  Since I am only trying to get a string, I simply used a text layer that shows the actual string I want, so from any other Composition, I just reference the sourceText.text property of that text layer as per Javascript's DOM.
    Thanks!

  • Which table stores all development class and names of programs

    Hi All,
    can any one tell me which table stores all development classes and programs we made.

    thanks for the answer , i got info also.
    TADIR is also one table in which you can find out the prog names and dev class.
    check table for dev class is TDEVC.

  • PL/SQL: How to make a function accessible to all users?

    How can I make a function accessible to all users?
    I have written a stored function called GET_NET_BALANCE.
    I can run it but my users cannot.
    I have tried the following, but my users still cannot
    run the function:
    GRANT EXECUTE ON GET_NET_BALANCE TO PUBLIC;
    Thanks, Eileen

    Hi,
    You can try creating a public synonym on the function so that it is accessible to all.
    To get greater response.. please post your question at
    PL/SQL
    Regards,
    Anupama

Maybe you are looking for

  • Performance problem in application

    Hi , I have some serious problems with my application on perfromance, when i check the db for events i can see the following Events Total_Waits Time Wauted 1     Data file init write     1794     9077 2     local write wait     24     63 3     read b

  • Error during Mapping

    Hello, My XI 2.0 scenario : Flat file => File adapter => XI => IDoc adapter => SAP 4.7 The File adapter reads the file successfully & passes to the Integration Server. In XI XML message monitor (SXMB_MONI), I'm getting the following error ... =======

  • JBO-33035 when usuing LOV in master-detail

    i have created a simple employee form with LOV on the department id and it's worked fine. but when i tried to attach the lov to an employee form which is in master-detail form (department-employee) i got jbo-33035 error i have tried to use the master

  • Mapped Drives Query SCCM 2012

    So in 2007 I extended the Sms Def MOF file and added a few lines so that mapped drives could be captured in hardware inventory. (Using the Datashift) I don't know how to do this in 2012 since for one the sms_def.mof file isn't used (its just the conf

  • Looking for the owner

    Yesterday, I found a Verizon Sony Ericsson Xper and am trying to find out how I can return it to the owner. Obviously I cannot get into the device without the code etc. to look for any phone number. Who could I call for help in finding the owner? Tha