Am I on the right track? Instead of parallel arrays I am doing this...

Hi.
I am making a phonebook aplication and am not allowed to use a database as yet for the application(will be converted into a database application at a later point.)
The code is not complete and I am aware that thereating are many things missing. I am not looking for replies state I still neeed to do this and that. I just want someone to look at my method for storing my object named contact and if the method I made to save the arraylist to file looks ok. Also will it be possible to CRUD the objects in my arrayList by using the contacts name as a reference only?

aplolgies here is my code.....
     Filename:     ContactsListInterface.java
     Date:           16 March 2008
     Programmer:     Yucca Nel
     Purpose:     Provides a GUI for entering names and contact numbers into a telephone directory.
                    Also allows options for searching for a specific name and deleting of data from the record
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.io.*;
import java.util.*;
import java.text.*;
public class Phonebook extends JFrame implements ActionListener
{ //start of class
     // construct fields, buttons, labels,text boxes, ArrayLists etc
     JTextPane displayPane = new JTextPane();
     JLabel listOfContacts = new JLabel("List Of Contacts");               // creates a label for the scrollpane
     JButton createButton = new JButton("Create");
     JButton searchButton = new JButton("Search");
     JButton modifyButton = new JButton("Modify");
     JButton deleteButton = new JButton("Delete");
     ArrayList contactList = new ArrayList();
     PhonebookDAO pdao = new PhonebookDAO();
     public String name, surname, home, work, cell;
     // create an instance of the ContactsListInterface
     public Phonebook()
     { // start of cli()
          super("Phonebook Interface");
     } // end of cli()
     public JMenuBar createMenuBar()
     { // start of the createMenuBar()
          // construct and populate a menu bar
          JMenuBar mnuBar = new JMenuBar();                    // creates a menu bar
          setJMenuBar(mnuBar);
          JMenu mnuFile = new JMenu("File",true);               // creates a file menu in the menu bar which is visible
               mnuFile.setMnemonic(KeyEvent.VK_F);
               mnuFile.setDisplayedMnemonicIndex(0);
               mnuFile.setToolTipText("File Options");
               mnuBar.add(mnuFile);
          JMenuItem mnuFileExit = new JMenuItem("Save And Exit");     // creates an exit option in the file menu
               mnuFileExit.setMnemonic(KeyEvent.VK_X);
               mnuFileExit.setDisplayedMnemonicIndex(1);
               mnuFileExit.setToolTipText("Close Application");
               mnuFile.add(mnuFileExit);
               mnuFileExit.setActionCommand("Exit");
               mnuFileExit.addActionListener(this);
          JMenu mnuEdit = new JMenu("Edit",true);               // creates a menu for editing options
               mnuEdit.setMnemonic(KeyEvent.VK_E);
               mnuEdit.setDisplayedMnemonicIndex(0);
               mnuEdit.setToolTipText("Edit Options");
               mnuBar.add(mnuEdit);
          JMenu mnuEditSort = new JMenu("Sort",true);          // creates an option for sorting entries
               mnuEditSort.setMnemonic(KeyEvent.VK_S);
               mnuEditSort.setDisplayedMnemonicIndex(0);
               mnuEdit.add(mnuEditSort);
          JMenuItem mnuEditSortByName = new JMenuItem("Sort By Name");          // to sort entries by name
               mnuEditSortByName.setMnemonic(KeyEvent.VK_N);
               mnuEditSortByName.setDisplayedMnemonicIndex(8);
               mnuEditSortByName.setToolTipText("Sort entries by first name");
               mnuEditSortByName.setActionCommand("Name");
               mnuEditSortByName.addActionListener(this);
               mnuEditSort.add(mnuEditSortByName);
          JMenuItem mnuEditSortBySurname = new JMenuItem("Sort By Surname");     // to sort entries by surname
               mnuEditSortBySurname.setMnemonic(KeyEvent.VK_R);
               mnuEditSortBySurname.setDisplayedMnemonicIndex(10);
               mnuEditSortBySurname.setToolTipText("Sort entries by surname");
               mnuEditSortBySurname.setActionCommand("Surname");
               mnuEditSortBySurname.addActionListener(this);
               mnuEditSort.add(mnuEditSortBySurname);
          JMenu mnuHelp = new JMenu("Help",true);                    // creates a menu for help options
               mnuHelp.setMnemonic(KeyEvent.VK_H);
               mnuHelp.setDisplayedMnemonicIndex(0);
               mnuHelp.setToolTipText("Help options");
               mnuBar.add(mnuHelp);
          JMenuItem mnuHelpHelp = new JMenuItem("Help");          // creates a help option for help topic
               mnuHelpHelp.setMnemonic(KeyEvent.VK_P);
               mnuHelpHelp.setDisplayedMnemonicIndex(3);
               mnuHelpHelp.setToolTipText("Help Topic");
               mnuHelpHelp.setActionCommand("Help");
               mnuHelpHelp.addActionListener(this);
               mnuHelp.add(mnuHelpHelp);
          JMenuItem mnuHelpAbout = new JMenuItem("About");     // creates a about option for info about api
               mnuHelpAbout.setMnemonic(KeyEvent.VK_T);
               mnuHelpAbout.setDisplayedMnemonicIndex(4);
               mnuHelpAbout.setToolTipText("About this program");
               mnuHelpAbout.setActionCommand("About");
               mnuHelpAbout.addActionListener(this);
               mnuHelp.add(mnuHelpAbout);
          return mnuBar;
     } // end of the createMenuBar()
     // create the content pane
     public Container createContentPane()
     { // start of createContentPane()
          //construct and populate panels and content pane
          JPanel labelPanel = new JPanel(); // panel is only used to put the label for the textpane in
               labelPanel.setLayout(new FlowLayout());
               labelPanel.add(listOfContacts);
          JPanel displayPanel = new JPanel();// panel is used to display all the contacts and thier numbers
               setTabsAndStyles(displayPane);
               displayPane = addTextToTextPane();
               displayPane.setEditable(false);
          JScrollPane scrollPane = new JScrollPane(displayPane);
               scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // pane is scrollable vertically
               scrollPane.setWheelScrollingEnabled(true);// pane is scrollable by use of the mouse wheel
               scrollPane.setPreferredSize(new Dimension(400,320));
          displayPanel.add(scrollPane);
          JPanel workPanel = new JPanel();// panel is used to enter, edit and delete data
               workPanel.setLayout(new FlowLayout());
               workPanel.add(createButton);
                    createButton.setToolTipText("Create a new entry");
                    createButton.addActionListener(this);
               workPanel.add(searchButton);
                    searchButton.setToolTipText("Search for an entry by name number or surname");
                    searchButton.addActionListener(this);
               workPanel.add(modifyButton);
                    modifyButton.setToolTipText("Modify an existing entry");
                    modifyButton.addActionListener(this);
               workPanel.add(deleteButton);
                    deleteButton.setToolTipText("Delete an existing entry");
                    deleteButton.addActionListener(this);
          labelPanel.setBackground(Color.red);
          displayPanel.setBackground(Color.red);
          workPanel.setBackground(Color.red);
          // create container and set attributes
          Container c = getContentPane();
               c.setLayout(new BorderLayout(30,30));
               c.add(labelPanel,BorderLayout.NORTH);
               c.add(displayPanel,BorderLayout.CENTER);
               c.add(workPanel,BorderLayout.SOUTH);
               c.setBackground(Color.red);
          // add a listener for the window closing and save
          addWindowListener(
               new WindowAdapter()
                    public void windowClosing(WindowEvent e)
                         int answer = JOptionPane.showConfirmDialog(null,"Are you sure you would like to save all changes and exit?","File submission",JOptionPane.YES_NO_OPTION);
                         if(answer == JOptionPane.YES_OPTION)
                              System.exit(0);
          return c;
     } // end of createContentPane()
     protected void setTabsAndStyles(JTextPane displayPane)
     { // Start of setTabsAndStyles()
          // set Font style
          Style fontStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
          Style regular = displayPane.addStyle("regular", fontStyle);
          StyleConstants.setFontFamily(fontStyle, "SansSerif");
          Style s = displayPane.addStyle("bold", regular);
          StyleConstants.setBold(s,true);
     } // End of setTabsAndStyles()
     public JTextPane addTextToTextPane()
     { // start of addTextToTextPane()
          Document doc = displayPane.getDocument();
          try
          { // start of tryblock
               // clear previous text
               doc.remove(0,doc.getLength());
               // insert titles of columns
               doc.insertString(0,"NAME\tSURNAME\tHOME NO\tWORK NO\tCELL NO\n",displayPane.getStyle("bold"));
          } // end of try block
          catch(BadLocationException ble)
          { // start of ble exception handler
               System.err.println("Could not insert text.");
          } // end of ble exception handler
          return displayPane;
     } // end of addTextToTextPane()
     // code to process user clicks
     public void actionPerformed(ActionEvent e)
     { // start of actionPerformed()
          String arg = e.getActionCommand();
          // user clicks create button
          if(arg.equals("Create"))
               createNewContact();
          if(arg.equals("Exit"))
               pdao.saveAndExit();
     } // end of actionPerformed()
     // method to create a new contact
     public void createNewContact()
     { // start of create new contact()
          name = JOptionPane.showInputDialog(null,"Please enter the contacts name or press cancel to exit");
          if(name == null)                                                       // user clicks cancel
          System.exit(0);
          if(name.length()<=0)
               JOptionPane.showMessageDialog(null,"You did not enter a valid name.\nPlease make sure you enter data correctly.","Error",JOptionPane.ERROR_MESSAGE);
               createNewContact();                                                  // To return to the create method
          else
               addTextToTextPane();
          surname = JOptionPane.showInputDialog(null,"Please enter the contacts surname or press cancel to exit");
          if(surname == null)                                                       // user clicks cancel
               System.exit(0);
          if(surname.length()<=0)
               JOptionPane.showMessageDialog(null,"You did not enter a valid surname.\nPlease make sure you enter data correctly.","Error",JOptionPane.ERROR_MESSAGE);
               createNewContact();                                                  // To return to the create method
          else
               addTextToTextPane();
          home = JOptionPane.showInputDialog(null,"Please enter the contacts home number or press cancel to exit");
          if(home == null)
          {                                                                           // user clicks cancel
               System.exit(0);
          else
               addTextToTextPane();
          work = JOptionPane.showInputDialog(null,"Please enter the contacts work number or press cancel to exit");
          if(work == null)
          {                                                                           // user clicks cancel
               System.exit(0);
          else
               addTextToTextPane();
          cell = JOptionPane.showInputDialog(null,"Please enter the contacts cell number or press cancel to exit");
          if(cell == null)
          {                                                                           // user clicks cancel
               System.exit(0);
          else
               addTextToTextPane();
          // create a contact object and pass it the DAO class that handles the saving of the object
          ContactInfo contact = new ContactInfo(name, surname, home, work, cell);
          pdao.CreateContact(contact);
     } // end of create new contact()
     public static void main(String[] args)
     { // start of main()
          // Set look and feel of interface
          try
          { // start of try block
               UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
          } // end of try block
          catch(Exception e)
          { // start of catch block
               JOptionPane.showMessageDialog(null,"There was an error in setting the look and feel of this application","Error",JOptionPane.INFORMATION_MESSAGE);
          } // end  of catch block
          Phonebook p = new Phonebook();
          p.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
          p.setJMenuBar(p.createMenuBar());
          p.setContentPane(p.createContentPane());
          p.setSize(520,500);
          p.setVisible(true);
          p.setResizable(false);
     } // end of main()
} //end of class
import java.io.*;
import java.util.*;
import javax.swing.*;
public class PhonebookDAO
     String filename = "phonebook";
     FileInputStream fIStream;
     FileOutputStream fOStream;
     ObjectInputStream oIStream;
     ObjectOutputStream oOStream;
     private ArrayList contactList;
     public PhonebookDAO()
          try
               fIStream = new FileInputStream(filename);
          catch(FileNotFoundException fnfe)
               JOptionPane.showMessageDialog(null,"Could not find file to read data from");
          catch(IOException ioe)
          try
               oIStream = new ObjectInputStream(fIStream);
          catch(IOException ioe)
               JOptionPane.showMessageDialog(null,"Could not load data from file","Error",JOptionPane.ERROR_MESSAGE);
          catch(NullPointerException npe)
          try
               contactList = (ArrayList)oIStream.readObject();
          catch(IOException ioe)
          catch(ClassNotFoundException cnfe)
          catch(NullPointerException npe)
     public void CreateContact(ContactInfo contact)
          try
               contactList.add(contact);
          catch(Exception e)
     public void saveAndExit()
          int answer = JOptionPane.showConfirmDialog(null,"Exiting will save all changes to file. \nAre you sure you would like to save and exit now?","File submission",JOptionPane.YES_NO_OPTION);
          if(answer == JOptionPane.YES_OPTION)
               try
                    fOStream = new FileOutputStream(filename);
               catch(IOException ioe)
                    JOptionPane.showMessageDialog(null,"Unable to create a file to save data to","Error",JOptionPane.ERROR_MESSAGE);
               try
                    oOStream = new ObjectOutputStream(fOStream);
               catch(IOException ioe)
                    JOptionPane.showMessageDialog(null,"Could not save data to file.","Error",JOptionPane.ERROR_MESSAGE);
               try
                    oOStream.writeObject(contactList);
               catch(IOException ioe)
                    JOptionPane.showMessageDialog(null,"Could not save data to file.","Error",JOptionPane.ERROR_MESSAGE);
               catch(NullPointerException npe)
               JOptionPane.showMessageDialog(null,"All data was succesfully saved.");
               System.exit(1);
public class ContactInfo
     String name = "";
     String surname = "";
     String home = "";
     String work = "";
     String cell = "";
     public ContactInfo(String name,String surname, String home,String work,String cell)
          this.name = name;
          this.surname = surname;
          this.home = home;
          this.work = work;
          this.cell = cell;
     // setters
     public void setName(String n)
          name = n;
     // getters
     public String getName()
          return name;
}

Similar Messages

  • I am trying to setup kvm. Am I on the right track?

    I am trying to  set up kvm and am a bit confused (probably by old information)
    lscpu
    Virtualization: AMD-V
    L1d cache: 16K
    L1i cache: 64K
    L2 cache: 2048K
    L3 cache: 8192K
    NUMA node0 CPU(s): 0-5
    grep -E "(vmx|svm|0xc0f)" --color=always /proc/cpuinfo
    Worked
    zgrep CONFIG_KVM /proc/config.gz
    CONFIG_KVM_GUEST=y
    # CONFIG_KVM_DEBUG_FS is not set
    CONFIG_KVM_APIC_ARCHITECTURE=y
    CONFIG_KVM_MMIO=y
    CONFIG_KVM_ASYNC_PF=y
    CONFIG_KVM_VFIO=y
    CONFIG_KVM=m
    CONFIG_KVM_INTEL=m
    CONFIG_KVM_AMD=m
    CONFIG_KVM_MMU_AUDIT=y
    CONFIG_KVM_DEVICE_ASSIGNMENT=y
    zgrep CONFIG_VIRTIO /proc/config.gz
    CONFIG_VIRTIO_BLK=m
    CONFIG_VIRTIO_NET=m
    CONFIG_VIRTIO_CONSOLE=m
    CONFIG_VIRTIO=m
    CONFIG_VIRTIO_PCI=m
    CONFIG_VIRTIO_BALLOON=m
    CONFIG_VIRTIO_MMIO=m
    CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
    lsmod | grep kvm
    kvm_amd 59131 0
    kvm 413027 1 kvm_amd
    lsmod | grep virtio
    [virtio_pci 17389 0
    virtio_balloon 12997 0
    virtio_scsi 17714 0
    virtio_blk 17295 0
    virtio_net 26460 0
    virtio_ring 17342 5 virtio_blk,virtio_net,virtio_pci,virtio_balloon,virtio_scsi
    virtio 13058 5 virtio_blk,virtio_net,virtio_pci,virtio_balloon,virtio_scsi
    scsi_mod 142915 4 libata,sd_mod,sr_mod,virtio_scsi
    Is there any thing else that needs to be set up before I install virt-manager
    Confused?
    thanks
    Dave
    Last edited by spottyrover (2014-09-10 04:08:08)

    1. tags around your raw output!1. [ code ] tags around your raw output! 1.
    Looks pretty now. Always wondered how that was done
    2. Did you deplete the usefulness of https://wiki.archlinux.org/index.php/KVM to its entirety?
    that is what I am trying to follow.
    Is there more modules needed?
    Did it work correctly?
    It lacks information on how to add modules.
    I got it  working the first time by following multiple how tos and in the end I do not know which bits I done was needed and which bits was not  and they did.
    By the way. You did not answer the question.
    Am I on the right track?
    After all I am in the newbie corner
    Dave
    Last edited by spottyrover (2014-09-10 04:28:24)

  • I want to know if i am on the right track

    'm still working on my DNA sequencing project (i am further along thank goodness) but now, i want to check my thought process.
    Okay, i have to write a new method public void addEdge(int i, int k)
    that creates an edge sequence between vertex j and k.
    What these need to do is take the watson-crick compliment of the last half of j concatenated with the watson-crick of the first half of k. So it looks kind of like this:
    sequence
    ATTATAAACCA
    watson-crick edge compliment
    TGGTTTATAAT
    here is my thought process
    1. take the initial sequence array and divide it by 2
    2. then go through the first half and change the compliments
    3. then do the same with the second half and concantenate them together
    so it would look like
    for(int i = 0; i < seqArray.length/2; i++){
    base = rand.nextInt(4);
    if(base==0)
    tube+="T";
    else if(base==1)
    tube+="A";
    else if(base==2)
    tube+="C";
    else if(base==3)
    tube+="G";
    for(int j = seqArray.length/2; j < seqArray.length; j++){
    base = rand.nextInt(4);
    if(base==0)
    tube+="T";
    else if(base==1)
    tube+="A";
    else if(base==2)
    tube+="C";
    else if(base==3)
    tube+="G";
    new Sequence(tube)= seqArray[i] + seqArray[j];What do you think? am i on the right track?
    }

    Something like the following?
    public class WC {
        private static char complement(char base) {
            switch (base) {
                case 'A': return 'T';
                case 'T': return 'A';
                case 'G': return 'C';
                case 'C': return 'G';
                default:
                    throw new IllegalArgumentException("unrecognised base "+base);
        private static char[] complement(char[] bases) {
            int size = bases.length;
            char[] complement = new char[size];
            for (int i = 0; i < size; i++) {
                complement[i] = complement(bases);
    return complement;
    public static void main(String[] args) {
    String s = args[0];
    String s1 = s.substring(0, s.length()/2);
    String s2 = s.substring(s.length()/2);
    char[] c1 = s1.toCharArray();
    char[] c2 = s2.toCharArray();
    s1 = new String(complement(c1));
    s2 = new String(complement(c2));
    System.out.println(s);
    System.out.println(s2+s1);
    Cheers, Neil

  • Calling a local Webservice from ECC ABAP - Am I on the right track?

    Hi all
    In my NW2004s landscape I have an ECC system (ABAP 6.40, Java not configured/linked) and an XI system (6.40).  My requirement is to call a Webservice (WS) from the ECC system.
    I've converted an existing Java class (that contains 3 methods) to a webservice (WS) using NWDS.  This WS has then been deployed to the XI system as it is the only one with a JAVA system.  I'm able to view and test the WS methods using the Web Service Navigator on the XI system.  The wsdl for the WS that was generated has the following format "http://<server>:<port>/<webservice name>/<configuration name>?wsdl  (No .asmx extension as per most of the examples on SDN...not sure if this matters).
    My understanding is that I should be able to create a client proxy in my ECC system (via Enterprise Services in SE80) using this wsdl and I can also configure a logical port throught txn LPCONFIG.  I should then be able to utilise ABAP to call this webservice? 
    I've found the blog "/people/thomas.jung3/blog/2004/11/17/bsp-a-developers-journal-part-xiv--consuming-webservices-with-abap detailing this (for a 6.40 system)... but when I attempt the program I get a soap 111 error code Unallowed RFC-XML Tag(SOAP_EINVALDOC).  
    Am I on the right track? Is it possible to call the Webservice from ECC ABAP? 
    There are no dumps for me to analyse and I've also tried putting on RFC trace with no success.
    Could it be that the WS is not correctly formed even though it works fine when tested from the WS Navigator on the XI system?
    Thanking you in advance.
    Malick

    Clive Pennington wrote:
    Thank you Eugene, your answer is most helpful.  I supose I just wanted to do everything myself really.  If when I have made my little movies, my animations and collated all my words and pictures I have problems assembling the documents then I can always get a professional to haul it together for me but I want to put in the donkey work first.  I know it is a lot of money for the software but now the pain is giving way a little I'm really quite enjoying myself.
    The planning which you have mentioned in your reply is of imense value I will start to do that immidiately, also the constant testing through Digital editions.
    All this is really helpful and I thank you for you reply.  I have made a brave attempt at some elementary annimation and posted them on youtube for testing, the urls are here if there is any interest.  Basic and time consuming but I can do this much faster now.
    http://tinyurl.com/348wjxg
    http://tinyurl.com/2wzuhql
    http://tinyurl.com/3yzjunk
    Thanks again............ Clive
    What comes through to me from your videos is that you know your material (of course, no pun intended) and that you have a clear sense of how to present it for clear communication to, and understanding by, your audience. Without this core, no amount of professional-level visual effects will achieve your goal, a great training program.
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • J2EE Design Question -- Am I On The Right Track?

    There are multiple tables in my database. Each table has a primary key, and the table that relates to other tables has foreign keys. I have to match the primary key and foreign key to go from one table to another. The specifics are spelled out below:
    The first table has login, pwd, and a primary key as fields, the second table contains completely different fields plus a primary key and foreign keys. The fields in the third table are different from those in the first and second tables plus its primary key. Queries to the third table can be made only if the user login and pwd are found in the first table, and through the second table's relation to the first table and the third table�s relation to the second table.
    The fields of all those tables may be accessed concurrently, but the fields are read-only (for the time being).
    I have a servlet to handle browser interactions. And I have a session bean to handle the workflow and business logic. However, I am confused with the choices between VO and entity beans.
    I first thought that I should use value objects to represent the data fields of the specific rows I looked for in those tables. Here is what I read about Value Object:
    "If a business object merely represents a structure to hold data fields, and the only behavior it provides are get and set method for the fields, then it would be wasteful of system resources to implement it as an enterprise bean. To avoid expensive remote methods calls (system resources and network bandwidth) to get the value of entity object fields, a value object is used to represent the details of the entity object. Only one remote call is required to retrieve the value object and then a client�s request to query the state of the object can then be met via local get methods on this details object."
    On my second thought, I think I should use entity beans to represent the specific rows I am looking for in those tables because I must use primary key and foreign key relations to go from one table to another.
    I do not use DAO because I am using CMP. The first call is within the session bean. It is a remote call to look for a specific row in the first table in my database. Subsequently, the mapping of the row in the first table to the second table, and the mapping of the row in the second table to the third table are all invoked on the �local" interfaces of those entity beans.
    client(browser)-->front controller(servlet)-->session facade(session ejb)-->entity ejb-->entity ejb -- > entity ejb
    Please advise if this is the right design. Am I on the right track? Is there improvement to be made?

    I might not explain my question well in my previous post -- there is no business logic involved in what I am doing to go from the first entity bean to the second entity bean and to go from the second entity bean to the third entity bean.
    Based on the login information, I have to go through those entity beans to find the very specific row in the third table in order to get the data field I need. That is to say, only thing involved is searching for rows.
    In my view, session bean -- > 1st entity bean -- > 2nd entity bean -- > 3rd entity bean
    1. session bean -- > 1st entity bean: remote call and returns the key to the 1st entity bean for locating the 2nd entity bean
    2. 1st entity bean -- > 2nd entity bean: local call and returns the key to the 2nd entity bean for locating the 3rd entity bean
    3. 2nd entity bean -- > 3rd entity bean: local call and then returns the value of the specific field to the session bean
    The alternative approach is:
    session bean
    |
    + + +
    1st entity bean 2nd entity bean 3rd entity bean
    1. session bean -- > 1st entity bean: remote call and returns the key to the session bean for locating the 2nd entity bean
    2. session bean -- > 2nd entity bean: remote call
    and returns the key to the session bean for locating the 3rd entity bean
    3. session bean -- > 3rd entity bean: remote call and the session bean can get the value of the specific field from the 3rd entity bean
    I do not know which approach to go for. Please provide guidance. Thanks.

  • Design Question -- Am I On The Right Track

    There are multiple tables in my database. Each table has a primary key, and the table that relates to other tables has foreign keys. I have to match the primary key and foreign key to go from one table to another. The specifics are spelled out below:
    The first table has login, pwd, and a primary key as fields, the second table contains completely different fields plus a primary key and foreign keys. The fields in the third table are different from those in the first and second tables plus its primary key. Queries to the third table can be made only if the user login and pwd are found in the first table, and through the second table's relation to the first table and the third table�s relation to the second table.
    The fields of all those tables may be accessed concurrently, but the fields are read-only (for the time being).
    I have a servlet to handle browser interactions. And I have a session bean to handle the workflow and business logic. However, I am confused with the choices between VO and entity beans.
    I first thought that I should use value objects to represent the data fields of the specific rows I looked for in those tables. Here is what I read about Value Object:
    "If a business object merely represents a structure to hold data fields, and the only behavior it provides are get and set method for the fields, then it would be wasteful of system resources to implement it as an enterprise bean. To avoid expensive remote methods calls (system resources and network bandwidth) to get the value of entity object fields, a value object is used to represent the details of the entity object. Only one remote call is required to retrieve the value object and then a client�s request to query the state of the object can then be met via local get methods on this details object."
    On my second thought, I think I should use entity beans to represent the specific rows I am looking for in those tables because I must use primary key and foreign key relations to go from one table to another.
    I do not use DAO because I am using CMP. The first call is within the session bean. It is a remote call to look for a specific row in the first table in my database. Subsequently, the mapping of the row in the first table to the second table, and the mapping of the row in the second table to the third table are all invoked on the �local" interfaces of those entity beans.
    client(browser)-->front controller(servlet)-->session facade(session ejb)-->entity ejb-->entity ejb -- > entity ejb
    Please advise if this is the right design. Am I on the right track? Is there improvement to be made?

    I might not explain my question well in my previous post -- there is no business logic involved in what I am doing to go from the first entity bean to the second entity bean and to go from the second entity bean to the third entity bean.
    Based on the login information, I have to go through those entity beans to find the very specific row in the third table in order to get the data field I need. That is to say, only thing involved is searching for rows.
    In my view, session bean -- > 1st entity bean -- > 2nd entity bean -- > 3rd entity bean
    1. session bean -- > 1st entity bean: remote call and returns the key to the 1st entity bean for locating the 2nd entity bean
    2. 1st entity bean -- > 2nd entity bean: local call and returns the key to the 2nd entity bean for locating the 3rd entity bean
    3. 2nd entity bean -- > 3rd entity bean: local call and then returns the value of the specific field to the session bean
    The alternative approach is:
    session bean
    |
    + + +
    1st entity bean 2nd entity bean 3rd entity bean
    1. session bean -- > 1st entity bean: remote call and returns the key to the session bean for locating the 2nd entity bean
    2. session bean -- > 2nd entity bean: remote call
    and returns the key to the session bean for locating the 3rd entity bean
    3. session bean -- > 3rd entity bean: remote call and the session bean can get the value of the specific field from the 3rd entity bean
    I do not know which approach to go for. Please provide guidance. Thanks.

  • Strategy Pattern, Am i on the right Track?

    The question:
    Design a small, prototype, application, which creates, stores and amends warehouse records. This may have little more than a StockItem class.
    Using each of the patterns Strategy, Decorator, Adaptor and in turn provide three different adaptations to your prototype application which will enable a user to view the warehouse records in at least three different ways, e.g. by location, alphabetically, by value, by quantity in stock, as continuous plain text, as formatted text, in a list pane, as a printout etc
    My Code
    package warehouse;
    public class StockItem
        private int id;
        private String describtion;
        private double price;
        private int  quantity;
        private String location;
        ViewByLocationBehavior locationVar;
        public StockItem()
        public void setId(int id)
            this.id=id;
        public int getId()
            return id;
        public void setDescribtion(String describtion)
            this.describtion=describtion;
        public String getDescribtion()
            return describtion;
         public void setPrice(double price)
            this.price=price;
        public double getPrice()
            return price;
        public void setQuantity(int quantity)
            this.quantity=quantity;
        public int getQuantity()
            return quantity;
        public void setLocation(String location)
            this.location=location;
        public String getLocation()
            return location;
        public void setViewByLocationBehavior(ViewByLocationBehavior locationVar )
            this.locationVar=locationVar;
       public void displayByLocation()
        locationVar.displayByLocation();
        public String toString()
            return String.format("%d %S %f %d %S",id ,describtion,price,quantity,location);
    }The interface
    package warehouse;
    public interface ViewByLocationBehavior
        void displayByLocation();
    }Concrete classes arepackage warehouse;
    public class PlainText extends StockItem implements ViewByLocationBehavior
        public void displayByLocation()
            System.out.println("Display PlainText");
    package warehouse;
    public class FormattedText extends StockItem implements ViewByLocationBehavior
        public void displayByLocation()
            System.out.println("Display Formatted Text ");
    package warehouse;
    public class ListPane extends StockItem implements ViewByLocationBehavior
        public void displayByLocation()
            System.out.println("Display ListPane");
    package warehouse;
    public class PrintOut extends StockItem implements ViewByLocationBehavior
        public void displayByLocation()
            System.out.println("Display PrintOut ");
    package warehouse;
    public class StockTest
        public static void main(String args[])
            StockItem obj = new StockItem();
            obj.setViewByLocationBehavior(new PlainText());
            obj.displayByLocation();
            System.out.println(obj.toString());
    }But my questions is Am i on the right track applying the Strategy pattern?
    Because next i will make the other Interfaces: View by alphabetically, by value, by quantity, and their Concrete Classes are
    Display as continuous plain text, formatted text, in a list pane, and printout.
    Each interface have four concrete classes
    Need your comments Please?

    But my questions is Am i on the right track applying
    the Strategy pattern?Your assignment explicitly calls for the strategy pattern:
    "> Using each of the patterns Strategy, Decorator,
    Adaptor and in turn provide three different
    adaptations to your prototype application which will
    enable a user to view the warehouse records in at
    least three different ways, e.g. by location,
    alphabetically, by value, by quantity in stock, as
    continuous plain text, as formatted text, in a list
    pane, as a printout etc"I'm not sure I care for that interface much. I would have expected something more like this (I'm not 100% sure about the parameter that I'd pass, if any):
    public interface StockItemFilter
        List<StockItem> filter(List<StockItem> unfilteredStockItems);
    }Now you'll pass in an unfiltered List of StockItems and return the List of appropriate StockItems filtered alphabetically, by location, etc. If you want to combine the fetching of StockItems with filtering, replace the unfiltered List with some Criterion.
    Your ViewByLocationBehavior doesn't seem to accept any input or return anything. What good is it?
    %

  • Selling Macbook and erasing and restoring to Lion.  Am I on the right track?

    Hi All,
    I'm planning to sell a Macbook from 2008 that originally came with Snow Leopard.  I have since upgraded it to Lion.   
    I've read the discussions and I think I'm on the right track.  So far, I restarted and held the command and R keys.  That brought me to Disk Utility.  I chose "Macintosh HD" from the left hand bar and the format of "Mac OS Extended (Journaled)", selected to erase it, and chose the 7 pass security option. 
    In addition to being able to choose "Macintosh HD" there was "Mac OS X Base System".  However, I don't think I was able to perform an erase function on that.  Perhaps I can just leave that alone.
    Anyway, I successfully erased Macintosh HD with 7 pass.  I assume my next step would be to reinstall Lion.  When I try to I'm told to connect to my wi fi network and re-install Lion from the Apple site.  I had previously upgraded to Lion using a thumb drive which I no longer have.  I guess I have no choice but to reinstall from the Apple site.  That's fine for me as long as I get it to work.
    Before doing so though I'd like to know whether I missed any steps.  Was there anything else I should have done before I go ahead and reinstall Lion?
    Also, will the person buying the Macbook be able to operate it since the Lion OS would be tied to my Apple ID?
    Thank you.

    Follow these instructions step by step to prepare a Mac for sale:
    Step One - Back up your data:
           A. If you have any Virtual PCs shut them down. They cannot be in their "fast saved" state. They must be shut down from inside Windows.
           B. Clone to an external drive using using Carbon Copy Cloner.
              1. Open Carbon Copy Cloner.
              2. Select the Source volume from the Select a source drop down menu on the left side.
              3. Select the Destination volume from the Select a destination drop down menu on the right
                  side.
              4. Click on the Clone button. If you are prompted about creating a clone of the Recovery HD be
                  sure to opt for that.
                   Destination means a freshly erased external backup drive. Source means the internal
                   startup drive.
    Step Two - Prepare the machine for the new buyer:
              1. De-authorize the computer in iTunes! De-authorize both iTunes and Audible accounts.
              2, Remove any Open Firmware passwords or Firmware passwords.
              3. Turn the brightness full up and volume nearly so.
              4. Turn off File Vault, if enabled.
              5. Disable iCloud, if enabled: See.What to do with iCloud before selling your computer
    Step Three - Install a fresh OS:
         A. Snow Leopard and earlier versions of OS X
              1. Insert the original OS X install CD/DVD that came with your computer.
              2. Restart the computer while holding down the C key to boot from the CD/DVD.
              3. Select Disk Utility from the Utilities menu; repartition and reformat the internal hard drive.
                  Optionally, click on the Security button and set the Zero Data option to one-pass.
              4. Install OS X.
              5. Upon completion DO NOT restart the computer.
              6. Shutdown the computer.
         B. Lion and Mountain Lion (if pre-installed on the computer at purchase*)
             Note: You will need an active Internet connection. I suggest using Ethernet if possible because
                       it is three times faster than wireless.
              1. Restart the computer while holding down the COMMAND and R keys until the Mac OS X
                  Utilities window appears.
              2. Select Disk Utility from the Mac OS X Utilities window and click on the Continue button.
              3. After DU loads select your startup volume (usually Macintosh HD) from the left side list. Click
                  on the Erase tab in the DU main window.
              4. Set the format type to Mac OS Extended (Journaled.) Optionally, click on the Security button
                  and set the Zero Data option to one-pass.
              5. Click on the Erase button and wait until the process has completed.
              6. Quit DU and return to the Mac OS X Utilities window.
              7. Select Reinstall Lion/Mountain Lion and click on the Install button.
              8. Upon completion shutdown the computer.
    *If your computer came with Lion or Mountain Lion pre-installed then you are entitled to transfer your license once. If you purchased Lion or Mountain Lion from the App Store then you cannot transfer your license to another party. In the case of the latter you should install the original version of OS X that came with your computer. You need to repartition the hard drive as well as reformat it; this will assure that the Recovery HD partition is removed. See Step Three above. You may verify these requirements by reviewing your OS X Software License.

  • Need to reinstall HTML DB - Am I on the right track????

    I have a problem with my admin password not working. This is on a single user computer with htmldb installed in a local personal Oracle 9 database that I use specifically for development and testing. I don't know why the HTML DB admin password stopped working as it is just a lower case version of the ADMIN name. I can still access the user I created and have been working with that. No one else has access to this computer - so somehow I managed to screw something up.
    My question is - if I drop / wipe out the FLOWS_020000 and FLOWS_FILES users and then reinstall HTML DB, and then recreate my admin and user(s), will this solve my problem??
    Is there anything else I need to do to restore HTML DB?? I assume the HTTP SERVER should still be ok?
    I guess what I really need is confirmation that I am on the right track and not about to totally screw up a partially functional HTML DB install.
    Thanks for your help
    Glenn

    Please ignore the above thread - problem solved. My brainfart. Did 2 installs - kept the handwritten docs for the wrong one. Tracing my way through the install program jarred the memory.
    Thanks for the help Mark
    Nothing like a little bit of public embarassment
    glenn

  • I would like to convert a continuous waveform (created in Labview with the waveform generator vi) into digital form...am I on the right track (see below)

    I would like to simulate a sample and hold circuit. I was thinking of using the zero order hold vi (for continuous to discrete conversion) in combination with the AC to DC vi? Am I on the right track, or could anyone suggest a better way to do this? Many thanks in advance! 

    Hi,
    The answer to this question was answered in the forum post below:
    http://forums.ni.com/t5/LabVIEW/How-can-I-create-and-sample-and-hold-circuit-in-Labview/m-p/2369050#...
    If this question is different then please clarify and let me know. 
    Regards
    Arham H
    Applications Engineer
    National Instruments

  • Am I on the right track with the 'secret'  OPTION key?

    Everyone has questions about 'sharing' itune libraries. I just wanted to know how to keep them separate!
    After reading I got this far:
    Hold down the option key to view a different library, internal or external as long as it is plugged in and on the desktop.
    How to open alternate iTune library
    What happens, it a dialog comes up saying that the other users folder is locked or I don't have permission to access.
    Troubleshooting permissions on locked folders
    then I found a lot of great key cuts (for iPod) too~but using the option key in various configurations;
    Keyboard shortcuts
    itunes is on an external drive which complicates things, i think. Am I on the right track if
    * have to partition the external HD, one for each user.
    * drag the actual user folder to the external drive
    * change itune music folder for each user to selected partition
    * select "copy files to itunes music folder..." (which I still don't really understand)
    * make sure sharing is on all the way around
    And another discussion of "add to library" and more info on how to use play lists would be helpful.
    Is there a less cumbersome way to
    Load itunes, load a particular library
    then add to it via a playlist?
    First Gen iMac G5 17"   Mac OS X (10.4.8)   iMac G3 350/6GB/1GB/OSX Panther

    See, on the external, I can't have three folders that all say iTunes music folder, each one belonging to a different user.
    Sure you can. Put them in separate folders (John's music, Mary's music and Sam's music).
    But you should be creating new iTunes folders, not simply iTunes music folders. The iTunes music folder is in the iTunes folders but so it the iTunes library file.
    Any reason you want the music separated? You can put it all in one library. Everyone uses the same and simply create a playlist of the music they want. This way, if you have any of the same music, you won't have it on the computer more than once.

  • Why does my text in Indesign start on the right side instead of the left?

    I have done something to the newsletter that I am working on, but I don't know what I did.
    Whenever I try to write a caption on a picture or try to type a piece of text for the newsletter, the cursor starts on the right side instead of the left and makes weird spacing and never lines up correctly.
    The only way I can get text to work now is to use a snipping tool and snip text from another program!

    With just the text tool selected, but no text boxes selected (or made), any change to the style of paragraphs or fonts etc is 'set' for the document. If you have clicked on the right alignment tool with nothing selected, then everything from then onwards will default to right align.
    If every document you've worked on is doing this, then open InDesign with no document open (so just the panels showing, but no file/doc open) and select left align with the text tool in use. Any setting made with InDesign like this, is default for any new document created. Colours, alignment, optical kerning, fonts, sizes, leading etc etc changed in this state, is the new default.

  • Could you please tell me if I am in the right track?

    I am required to develop a online shopping web application which uses JSP and EJB. The first page I need to create is the login page. I would like to know if I am in the right track to implement this system in EJB design pattern.
    I got the following classes:
    User.java
    ===============================
    package assignment;
    import java.rmi.*;
    import javax.ejb.*;
    import java.util.Vector;
    public interface User extends EJBObject {
         public boolean Login(String id,String pwd,String role) throws RemoteException;
         public Vector getMusicCategories() throws RemoteException;
         public Vector getCategoryItems(String category) throws RemoteException;
         public MusicRecording getMusicRecording(String id) throws RemoteException;
    }UserHome.java
    ========================
    package assignment;
    import java.rmi.*;
    import javax.ejb.*;
    public interface UserHome extends EJBHome {
         public User create() throws RemoteException, CreateException;
    }UserBean.java
    ====================
    package assignment;
    import java.rmi.*;
    import javax.ejb.*;
    import java.util.Vector;
    public class UserBean implements SessionBean {
         // data item to hold a reference to a passed Session context
         private SessionContext ctx;
         // save the session context
         public void setSessionContext(SessionContext x) { ctx = x;}
         // the various method implementations
         // imposed on us by interface
         public void ejbCreate() {}
         public void ejbActivate() {}
         public void ejbPassivate() {}
         public void ejbRemove() {}
         public boolean Login(String id,String pwd,String role) throws RemoteException{
         } //returns true if the user is invalid,else returns false
         public Vector getMusicCategories() throws RemoteException{
         public Vector getCategoryItems(String category) throws RemoteException{
    public MusicRecording getMusicRecording(String id) throws RemoteException{
    }Login.jsp
    ====================
    <%@ page import="Assignment.User,Assignment.UserHome,javax.ejb.*, java.math.*, javax.naming.*, javax.rmi.PortableRemoteObject, java.rmi.RemoteException" %>
    <%!
       private User u = null;
       public void jspInit() {
          try {
             InitialContext ic = new InitialContext();
             Object objRef = ic.lookup("UserBean");
             UserHome home = (UserHome )PortableRemoteObject.narrow(objRef, UserHome.class);
             u = home.create();
          } catch (RemoteException ex) {
                System.out.println("Remote Exception:"+ ex.getMessage());
          } catch (CreateException ex) {
                System.out.println("Create Exception:"+ ex.getMessage());
          } catch (NamingException ex) {
                System.out.println("Unable to lookup home: "+ ex.getMessage());
       public void jspDestroy() {   
             u = null;
    %>
    <html>
    <head>
    </head>
    <body bgcolor="#0066CC">
    <h1><b><font color="#FFFFFF">E Music CD Shopping System</font></b></h1>
    <hr>
    <br>
    <br>
    <form name="login" method="get">
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="259">
      <tr>
        <td width="33%" height="46" align="center"><b><font color="#FFFFFF">User ID:</font></b></td>
        <td width="33%" height="46"><input type="text" name="id" size="20"></td>
        <td width="34%" height="46">&#12288;</td>
      </tr>
      <tr>
        <td width="33%" height="68" align="center"><b><font color="#FFFFFF">Password:</font></b></td>
        <td width="33%" height="68"><input type="password" name="pwd" size="20"></td>
        <td width="34%" height="68">&#12288;</td>
      </tr>
      <tr>
        <td width="33%" height="59" align="center"><b><font color="#FFFFFF">Role:</font></b></td>
        <td width="33%" height="59"><select size="1" name="role">
        <option value="Member">Member</option>
        <option value="Admin">Admin</option>
        </select></td>
        <td width="34%" height="59">&#12288;</td>
      </tr>
      <tr>
        <td width="100%" colspan="3" height="83"><center><input type="submit" value="Submit"><input type="reset" value="Reset"></center></td>
      </tr>
    </table>
    </form>
    </body>
    </html>
    <%
    String id=request.getParameter("id");
    String pwd=request.getParameter("pwd");
    String role=request.getParameter("role");
    boolean validUser=false;
    if(id!=null && pwd!=null && role!=null) {
    validUser=u.Login(id,pwd,role);
    if (validUser==true)
    response.sendRedirect("main.jsp"); //go the the main page of the system.
    else
    response.sendRedirect("loginfailed.jsp");
    else {
    response.sendRedirect("loginfailed.jsp");
    %>Please help me.
    Any advice would be very much appreciated.
    Many thanks to you all.

    EJB stuff looks ok.
    The only comment I could make is that the UserBean should probably implement the User interface
    Mixing JSP and scriptlet code is bad.
    If you need to do java code most of the time that should be in a Servlet, which then uses the request dispatcher to forward to a jsp to display the result.
    The entire java code for retrieving the EJB and testing for login could be in a servlet. It is completely unrelated to displaying a login page.
    Cheers,
    evnafets

  • HT4759 Can I track my iPhone from my iPad if I have not activated the 'find my iPhone' on my mobile? Or does this need to be set up already in order to search for my phone?

    Can I track my iPhone from my iPad if I have not activated the 'find my iPhone' on my mobile? Or does this need to be set up already in order to search for my phone?

    No.
    You needed to have set it up prior.

  • When I open iTunes I get a message that all the files in my library are "unchecked." What does this mean and how do I fix it?

    When I open iTunes, I get a message that the files in my library are "unchecked." What does this mean and how do I fix it?

    Windows - Ctrl-clicking a checkbox causes all tracks in the current display to become checked or unchecked.
    Additional suggestions in connection with syncing - https://discussions.apple.com/message/19096229

Maybe you are looking for

  • Customer Dates in Activity

    We have added some custom dates to our date profile for activities. We woulod like to transfer these dates to BW. Is there an easy way to do this, or do I need to enhance the datasource etc.? Does anybody have a list of the steps I will need to go th

  • I have a Windows XP Pro PC and Can't Get it to Connect to an Airport Wireless network

    Hi, I'm kinda at my wit's end here. I have a desktop PC using Windows XP Pro operating system. To get wireless, I'm using an external wireless d-link USB. It works fine on my home network. I took the desktop to my local repair guy. There's nothing wr

  • Why does mi iPad return to the home screen when I am searching the net?

    Home screen

  • No Problems @ all

    Hi there, I know this could sound strange for the philosophy of the Forums, but I felt I should post this because most of the times, when I access these Forums is mainly because I have a problem. Sure this is how the Forums were conceived and that's

  • I BEG FOR HELP "INSTALLATION ENCOUNTERED ERRORS"????

    I'm growing more and more upset with this program and soon to be company. I love what you do, but I hate how you help. I have had the same problem for THREE MONTHS, and customer service has yet to help! I have lost two hundred dollars since I was una