Help needed, Createing Dynamic User input

Hello,
I am attempting to create some dynamic user input by "predicting" what the user requires in a text box.
For example if the user enters "Smi" I have a select list pop up which gives the user all options that begin with "Smi".
I am able to achieve the popups but the interface is quite jerky and not terribly responsive I am trying to solve this by using a thread which starts and stops when new input is received but it is still not quite right.
The program uses a Sorted TreeSet to hold the data (I thought this would give me a quick search time) and a simple interface at this stage.
Any help would be fantastic
Thanks in advance :P
import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.text.*;
import java.util.*;
   /** This program represents part of a larger user interface for allowing the
   user to select data from a file or database.
   <p>
   When the program starts up, it will read in data from a given file, and hold
   it in some type of container allowing rapid access.
   <p>
   The user may then type in the first few letters of the surname of a person,
   and this program should immediately present in a popup dialog the names which
   match.  The user will be able to click on one of the names in the popup and
   that will cause all data about that person to be displayed in the JTextArea
   at the bottom of the window.
   <p>
   This program requires the FormLayout.class, FormLayout$Placement.class, and
   FormLayout$Constraint.class files in the same directory
   (folder) or in its classpath.  These is provided separately.
class PartMatch extends JFrame implements Runnable
                    /** Close down the program. */
   JButton quitbtn;
                    /** Field for the surname. */
   JTextField namefld;
                    /** Full details of the person(s). */
   JTextArea  results;
                    /** Popup dialog to display the names and addresses which
                    match the leading characters given in namefld. */
   Chooser matches;
                  /** Default background color for a window. */
   final static  Color            defBackground = new Color(0xD0C0C0);
                  /** Default foreground color for a window. */
   final static  Color            defForeground = new Color(0x000000);
                  /** Default background color for a field */
   final static  Color            fldBackground = new Color(0xFFFFFF);
                  /** Default background color for a button */
   final static  Color            btnBackground = new Color(0xF0E0E0);
   final static  Color            dkBackground = new Color(0xB0A0A0);
                  /** Larger font */
   final static  Font bold = new Font("Helvetica", Font.BOLD, 30);
   TreeSet members;
   String input;
   String[] found;
   public static void main(String arg[])
      UIManager.put("TextField.background",fldBackground);
      UIManager.put("TextField.foreground",defForeground);
      UIManager.put("TextField.selectionBackground",btnBackground);
      UIManager.put("TextArea.background",fldBackground);
      UIManager.put("TextArea.foreground",defForeground);
      UIManager.put("TextArea.selectionBackground",btnBackground);
      UIManager.put("Panel.background",defBackground);
      UIManager.put("Label.background",defBackground);
      UIManager.put("Label.foreground",defForeground);
      UIManager.put("Button.background",btnBackground);
      UIManager.put("Button.foreground",defForeground);
      UIManager.put("CheckBox.background",defBackground);
      UIManager.put("ScrollBar.background",defBackground);
      UIManager.put("ScrollBar.thumb",btnBackground);
      UIManager.put("ComboBox.background",btnBackground);
      UIManager.put("ComboBox.selectionBackground",dkBackground);
      PartMatch trial = new PartMatch(arg);
   public PartMatch( String [] arg )
      super("Part Match");
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      Container cpane = getContentPane();
      FormLayout form = new FormLayout(cpane);
      JLabel lab1 = new JLabel("Fetch details") ;
      lab1.setFont( bold );
      form.setTopAnchor( lab1, 4 );
      form.setLeftAnchor( lab1, 4 );
      JLabel lab2 = new JLabel("Surname: ") ;
      form.setTopRelative( lab2, lab1, 4 );
      form.setLeftAlign( lab2, lab1 );
      namefld = new JTextField( 30 );
      form.setBottomAlign( namefld, lab2 );
      form.setLeftRelative( namefld, lab2, 4 );
      namefld.addCaretListener( new CaretListener()
         public void caretUpdate(CaretEvent e)
             showMatches();
      quitbtn = new JButton( "Quit" );
      quitbtn.addActionListener( new ActionListener()
         public void actionPerformed(ActionEvent e)
            quitProcessing();
      form.setBottomAlign( quitbtn, namefld );
      form.setLeftRelative( quitbtn, namefld, 15 );
      results = new JTextArea( 10,50 );
      results.setEditable(false);
      JScrollPane jsp = new JScrollPane( results,
                                 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
      form.setTopRelative( jsp, lab2, 6 );
      form.setLeftAlign( jsp, lab2 );
      form.setBottomAnchor( jsp, 5 );
      form.setRightAnchor( jsp, 5 );
      form.setRightAnchor( quitbtn, 5 );
      matches = new Chooser( this );
      //matches.setUndecorated(true);
      pack();
      setVisible(true);
      namefld.requestFocus();
      if (arg.length > 0) init(arg[0]);
      else init("triathlon.txt"); //<<<<<<<<<<<<<<<< Place the default filename here
      /** Called once only, at the end of the constructor, to read the data
        * from the membership file.
   public void init( String fname )
      members = new TreeSet();
       try {
           FileReader fr = new FileReader(new File (fname));
           Scanner scan = new Scanner(fr);
           trimember cmem;
           String cLine, eTag, memberNo, first, last, gender, yob, tel ,addr,
                   club;
           while(scan.hasNextLine())
               cLine = scan.nextLine();
               Scanner scan2 = new Scanner(cLine);
               scan2.useDelimiter(";");
               eTag = scan2.next().trim();
               memberNo = scan2.next().trim();
               first = scan2.next().trim();
               last = scan2.next().trim();
               gender = scan2.next().trim();
               yob = scan2.next().trim();
               tel = scan2.next().trim();
               addr = scan2.next().trim();
               club = scan2.next().trim();
               cmem = new trimember(eTag, memberNo, first, last, gender, yob,
                       tel, addr, club);
               members.add(cmem);
       catch (FileNotFoundException ex)
           results.append("Sorry can't find the input file\n");
           results.append("Please check file name and location and try again");
           ex.printStackTrace();
      /** Called every time there is a change in the contents of the text field
        * namefld.  It will first clear the text area.  It then needs to search
        * through the container of data to find all records where the surname
        * starts with the characters that have been typed.  The names and
        * addresses need to be set up as strings and placed in
        * an array of Strings.  This can be placed in the "matches" window and
        * displayed for the user, inviting one to be selected.
        * <p>
        * The performance of this is very important.  If necessary, it may be
        * necessary to run as a separate thread so that the user interface is
        * not delayed.  It is essential that the user be able to type letters at a
        * reasonable speed and not have the keystroke processing held up by
        * previous text.
   public void showMatches( )
       run();
            // First clear the text area
      //results.setText("");
            // Determine the leading characters of the surname that is wanted
            input = namefld.getText();
            // Locate the data for this name, and display each matching item
            //  in the JTextArea ...
            // Example of how to set the data in the popup dialog
      matches.list.setListData(found);
      matches.pack();   // resize the popup
            // set the location of the popup if it is not currently visible
      if ( ! matches.isVisible())
         Dimension sz = matches.getSize();
         Point mouse = getMousePosition();
         Point framepos = getLocation();
         int x=0, y=0;
         if (mouse == null)
            Point pt = results.getLocation();
            x = pt.x + 20 + framepos.x;
            y = pt.y + 20 + framepos.y;
         else
            x = mouse.x - 2 + framepos.x;
            y = mouse.y - 2 + framepos.y;
         matches.setLocation(x,y);
      matches.setVisible(true);
      namefld.requestFocus();
      /** Perform any final processing before closing down.
   public void quitProcessing( )
      // Any closing work.  Then
      System.exit(0);
    public void run()
        ArrayList<String> foundit = new ArrayList<String>();
        System.out.println(input);
        if(input != null)
        Iterator it = members.iterator();
        while(it.hasNext())
           trimember test = (trimember) it.next();
           if (test.last.startsWith(input))
               foundit.add(test.last +", "+ test.first);
        found = new String[foundit.size()];
        for(int i=0; i<foundit.size();i++)
            found[i] = foundit.get(i);
     /** A window for displaying names and addresses from the data set which
      match the leading characters in namefld.
      <p>
      This will automatically pop down if the user moves the mouse out of the
      window.
      <p>
      It needs code added to it to respond to the user clicking on an item in
      the displayed list. */
   class Chooser extends JWindow
            /** To display a set of names and addresses that match the leading
            characters of the namefld text field. */
      public JList list = new JList();
      Chooser( JFrame parent )
         super( parent );
         Container cpane = getContentPane();
         cpane.addMouseListener( new MouseAdapter()
            public void mouseExited(MouseEvent e)
               Chooser.this.setVisible(false);
         cpane.add("Center",list);
         list.addListSelectionListener( new ListSelectionListener()
            public void valueChanged(ListSelectionEvent e)
               Chooser.this.setVisible(false);
               System.out.println("ValueChanged");
               // First clear the text area
               results.setText("");
               String in = (String) list.getSelectedValue();
               System.out.println("Selected Value was : "+in);
               String[] inlf = in.split(", ");
               System.out.println("inlf[0]:"+inlf[0]+" inlf[1]:"+inlf[1]);
               results.append("Surname \tFirst \teTag \tMemberNo \tSex \tYOB " +
                       "\tTel \tAddress \t\t\tClub\n");
               Iterator it = members.iterator();
               while(it.hasNext())
                   trimember test = (trimember) it.next();
                   if (test.last.equals(inlf[0])&&test.first.equals(inlf[1]))
                       results.append(test.toString()+"\n");
               namefld.requestFocus();
      public class trimember implements Comparable
       String eTag;
       public String memberNo;
       public String first;
       public String last;
       String gender;
       String yob;
       String tel;
       String addr;
       String club;
       public trimember(String eT, String me, String fi, String la,
               String ge, String yo, String te, String ad, String cl)
           eTag = eT;
           memberNo = me;
           first = fi;
           last = la;
           gender = ge;
           yob = yo;
           tel = te;
           addr = ad;
           club = cl;         
       //To String method to output string of details
       public String toString()
           return last + "\t" + first + "\t" + eTag + "\t" +
                   memberNo + "\t" + gender + "\t" + yob + "\t"+ tel + "\t" +
                   addr + "\t" + club;
       //Compare and sort on Last name
       public int compareTo(Object o)
           trimember com = (trimember) o;
           int lastCmp = last.compareTo(com.last);
           int firstCmp = first.compareTo(com.first);
           int memCmp = memberNo.compareTo(com.memberNo);
           if (lastCmp == 0 && firstCmp !=0)return firstCmp;
           else if (lastCmp==0&&firstCmp==0)return memCmp;
           else return lastCmp;
}

Please don't cross-post. It is considered very rude to do that here:
http://forum.java.sun.com/thread.jspa?messageID=9953193

Similar Messages

  • Help needed, Providing Dynamic User input

    Hello,
    I am attempting to create some dynamic user input by "predicting" what the user requires in a text box.
    For example if the user enters "Smi" I have a select list pop up which gives the user all options that begin with "Smi".
    I am able to achieve the popups but the interface is quite jerky and not terribly responsive I am trying to solve this by using a thread which starts and stops when new input is received but it is still not quite right.
    The program uses a Sorted TreeSet to hold the data (I thought this would give me a quick search time) and a simple interface at this stage.
    Any help would be fantastic
    Thanks in advance :P
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.text.*;
    import java.util.*;
       /** This program represents part of a larger user interface for allowing the
       user to select data from a file or database.
       <p>
       When the program starts up, it will read in data from a given file, and hold
       it in some type of container allowing rapid access.
       <p>
       The user may then type in the first few letters of the surname of a person,
       and this program should immediately present in a popup dialog the names which
       match.  The user will be able to click on one of the names in the popup and
       that will cause all data about that person to be displayed in the JTextArea
       at the bottom of the window.
       <p>
       This program requires the FormLayout.class, FormLayout$Placement.class, and
       FormLayout$Constraint.class files in the same directory
       (folder) or in its classpath.  These is provided separately.
    class PartMatch extends JFrame implements Runnable
                        /** Close down the program. */
       JButton quitbtn;
                        /** Field for the surname. */
       JTextField namefld;
                        /** Full details of the person(s). */
       JTextArea  results;
                        /** Popup dialog to display the names and addresses which
                        match the leading characters given in namefld. */
       Chooser matches;
                      /** Default background color for a window. */
       final static  Color            defBackground = new Color(0xD0C0C0);
                      /** Default foreground color for a window. */
       final static  Color            defForeground = new Color(0x000000);
                      /** Default background color for a field */
       final static  Color            fldBackground = new Color(0xFFFFFF);
                      /** Default background color for a button */
       final static  Color            btnBackground = new Color(0xF0E0E0);
       final static  Color            dkBackground = new Color(0xB0A0A0);
                      /** Larger font */
       final static  Font bold = new Font("Helvetica", Font.BOLD, 30);
       TreeSet members;
       String input;
       String[] found;
       public static void main(String arg[])
          UIManager.put("TextField.background",fldBackground);
          UIManager.put("TextField.foreground",defForeground);
          UIManager.put("TextField.selectionBackground",btnBackground);
          UIManager.put("TextArea.background",fldBackground);
          UIManager.put("TextArea.foreground",defForeground);
          UIManager.put("TextArea.selectionBackground",btnBackground);
          UIManager.put("Panel.background",defBackground);
          UIManager.put("Label.background",defBackground);
          UIManager.put("Label.foreground",defForeground);
          UIManager.put("Button.background",btnBackground);
          UIManager.put("Button.foreground",defForeground);
          UIManager.put("CheckBox.background",defBackground);
          UIManager.put("ScrollBar.background",defBackground);
          UIManager.put("ScrollBar.thumb",btnBackground);
          UIManager.put("ComboBox.background",btnBackground);
          UIManager.put("ComboBox.selectionBackground",dkBackground);
          PartMatch trial = new PartMatch(arg);
       public PartMatch( String [] arg )
          super("Part Match");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          Container cpane = getContentPane();
          FormLayout form = new FormLayout(cpane);
          JLabel lab1 = new JLabel("Fetch details") ;
          lab1.setFont( bold );
          form.setTopAnchor( lab1, 4 );
          form.setLeftAnchor( lab1, 4 );
          JLabel lab2 = new JLabel("Surname: ") ;
          form.setTopRelative( lab2, lab1, 4 );
          form.setLeftAlign( lab2, lab1 );
          namefld = new JTextField( 30 );
          form.setBottomAlign( namefld, lab2 );
          form.setLeftRelative( namefld, lab2, 4 );
          namefld.addCaretListener( new CaretListener()
             public void caretUpdate(CaretEvent e)
                 showMatches();
          quitbtn = new JButton( "Quit" );
          quitbtn.addActionListener( new ActionListener()
             public void actionPerformed(ActionEvent e)
                quitProcessing();
          form.setBottomAlign( quitbtn, namefld );
          form.setLeftRelative( quitbtn, namefld, 15 );
          results = new JTextArea( 10,50 );
          results.setEditable(false);
          JScrollPane jsp = new JScrollPane( results,
                                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
          form.setTopRelative( jsp, lab2, 6 );
          form.setLeftAlign( jsp, lab2 );
          form.setBottomAnchor( jsp, 5 );
          form.setRightAnchor( jsp, 5 );
          form.setRightAnchor( quitbtn, 5 );
          matches = new Chooser( this );
          //matches.setUndecorated(true);
          pack();
          setVisible(true);
          namefld.requestFocus();
          if (arg.length > 0) init(arg[0]);
          else init("triathlon.txt"); //<<<<<<<<<<<<<<<< Place the default filename here
          /** Called once only, at the end of the constructor, to read the data
            * from the membership file.
       public void init( String fname )
          members = new TreeSet();
           try {
               FileReader fr = new FileReader(new File (fname));
               Scanner scan = new Scanner(fr);
               trimember cmem;
               String cLine, eTag, memberNo, first, last, gender, yob, tel ,addr,
                       club;
               while(scan.hasNextLine())
                   cLine = scan.nextLine();
                   Scanner scan2 = new Scanner(cLine);
                   scan2.useDelimiter(";");
                   eTag = scan2.next().trim();
                   memberNo = scan2.next().trim();
                   first = scan2.next().trim();
                   last = scan2.next().trim();
                   gender = scan2.next().trim();
                   yob = scan2.next().trim();
                   tel = scan2.next().trim();
                   addr = scan2.next().trim();
                   club = scan2.next().trim();
                   cmem = new trimember(eTag, memberNo, first, last, gender, yob,
                           tel, addr, club);
                   members.add(cmem);
           catch (FileNotFoundException ex)
               results.append("Sorry can't find the input file\n");
               results.append("Please check file name and location and try again");
               ex.printStackTrace();
          /** Called every time there is a change in the contents of the text field
            * namefld.  It will first clear the text area.  It then needs to search
            * through the container of data to find all records where the surname
            * starts with the characters that have been typed.  The names and
            * addresses need to be set up as strings and placed in
            * an array of Strings.  This can be placed in the "matches" window and
            * displayed for the user, inviting one to be selected.
            * <p>
            * The performance of this is very important.  If necessary, it may be
            * necessary to run as a separate thread so that the user interface is
            * not delayed.  It is essential that the user be able to type letters at a
            * reasonable speed and not have the keystroke processing held up by
            * previous text.
       public void showMatches( )
           run();
                // First clear the text area
          //results.setText("");
                // Determine the leading characters of the surname that is wanted
                input = namefld.getText();
                // Locate the data for this name, and display each matching item
                //  in the JTextArea ...
                // Example of how to set the data in the popup dialog
          matches.list.setListData(found);
          matches.pack();   // resize the popup
                // set the location of the popup if it is not currently visible
          if ( ! matches.isVisible())
             Dimension sz = matches.getSize();
             Point mouse = getMousePosition();
             Point framepos = getLocation();
             int x=0, y=0;
             if (mouse == null)
                Point pt = results.getLocation();
                x = pt.x + 20 + framepos.x;
                y = pt.y + 20 + framepos.y;
             else
                x = mouse.x - 2 + framepos.x;
                y = mouse.y - 2 + framepos.y;
             matches.setLocation(x,y);
          matches.setVisible(true);
          namefld.requestFocus();
          /** Perform any final processing before closing down.
       public void quitProcessing( )
          // Any closing work.  Then
          System.exit(0);
        public void run()
            ArrayList<String> foundit = new ArrayList<String>();
            System.out.println(input);
            if(input != null)
            Iterator it = members.iterator();
            while(it.hasNext())
               trimember test = (trimember) it.next();
               if (test.last.startsWith(input))
                   foundit.add(test.last +", "+ test.first);
            found = new String[foundit.size()];
            for(int i=0; i<foundit.size();i++)
                found[i] = foundit.get(i);
         /** A window for displaying names and addresses from the data set which
          match the leading characters in namefld.
          <p>
          This will automatically pop down if the user moves the mouse out of the
          window.
          <p>
          It needs code added to it to respond to the user clicking on an item in
          the displayed list. */
       class Chooser extends JWindow
                /** To display a set of names and addresses that match the leading
                characters of the namefld text field. */
          public JList list = new JList();
          Chooser( JFrame parent )
             super( parent );
             Container cpane = getContentPane();
             cpane.addMouseListener( new MouseAdapter()
                public void mouseExited(MouseEvent e)
                   Chooser.this.setVisible(false);
             cpane.add("Center",list);
             list.addListSelectionListener( new ListSelectionListener()
                public void valueChanged(ListSelectionEvent e)
                   Chooser.this.setVisible(false);
                   System.out.println("ValueChanged");
                   // First clear the text area
                   results.setText("");
                   String in = (String) list.getSelectedValue();
                   System.out.println("Selected Value was : "+in);
                   String[] inlf = in.split(", ");
                   System.out.println("inlf[0]:"+inlf[0]+" inlf[1]:"+inlf[1]);
                   results.append("Surname \tFirst \teTag \tMemberNo \tSex \tYOB " +
                           "\tTel \tAddress \t\t\tClub\n");
                   Iterator it = members.iterator();
                   while(it.hasNext())
                       trimember test = (trimember) it.next();
                       if (test.last.equals(inlf[0])&&test.first.equals(inlf[1]))
                           results.append(test.toString()+"\n");
                   namefld.requestFocus();
          public class trimember implements Comparable
           String eTag;
           public String memberNo;
           public String first;
           public String last;
           String gender;
           String yob;
           String tel;
           String addr;
           String club;
           public trimember(String eT, String me, String fi, String la,
                   String ge, String yo, String te, String ad, String cl)
               eTag = eT;
               memberNo = me;
               first = fi;
               last = la;
               gender = ge;
               yob = yo;
               tel = te;
               addr = ad;
               club = cl;         
           //To String method to output string of details
           public String toString()
               return last + "\t" + first + "\t" + eTag + "\t" +
                       memberNo + "\t" + gender + "\t" + yob + "\t"+ tel + "\t" +
                       addr + "\t" + club;
           //Compare and sort on Last name
           public int compareTo(Object o)
               trimember com = (trimember) o;
               int lastCmp = last.compareTo(com.last);
               int firstCmp = first.compareTo(com.first);
               int memCmp = memberNo.compareTo(com.memberNo);
               if (lastCmp == 0 && firstCmp !=0)return firstCmp;
               else if (lastCmp==0&&firstCmp==0)return memCmp;
               else return lastCmp;
    }Edited by: Roger on Nov 3, 2007 11:50 AM

    Please don't cross-post. It is considered very rude to do that here:
    http://forum.java.sun.com/thread.jspa?threadID=5233033&messageID=9953169#9953169

  • Help with creating a user input BTree for hierarchy structure

    I have been trying to create code that takes a user input string
    ex: a:b,c;b:g,h,j;g:k,m;b:u
    note: (the above string is then stored into a string array such in the format a:bc;b:ghj;g:km;b:u after it is verified that the hierarchy order is correct)
    The string is read in such that the any value before the : is a parent and its childern continue until a ; is found. Anyway verifying the sting I have accomplished and I have been able to input the string into a modified binary tree as long as there are only 2 childern per parent and graphically represents its structure of hierarchy. The problem is that each parent can have more the two childern.
    I have been working with the BTree class and find its output similar to what I am wanting which would represent a hierarchy of objects (files, employees, etc...) anyway I have been stumped as to how to get the above string into a format that can then create the correct BTree output without hard code.
    If any one has any suggestions on how to turn the data, in the string array into a usable format to create the correct BTree output, I would greatly appreciate it.
    In the above example the string array, a:bc;b:ghj;g:km;b:u would have a desired ouput of
    a
    ..b
    ....g
    ......k
    ......m
    ....h
    ....j
    ....u
    ..c
    Thanks
    Shane

    OOPS! I ment to say JTree not BTree

  • How to create an user input variable for customer exit variable? - BW3.5

    Hi Guru,
    I have a requirement for the selection period of my reports. There are 3 possible reporting periods which should be user selectable:
    1. Month: Current reporting month
    2. Fiscal Year to Date
    3. Project Year to Date
    Here I need 2 variable to do these, 1 customer exit and 1 user input variable. I have created a variable customer exit to calculate all these requirement. But can any1 tell on how to create the user input variable for my customer exit? I need a user input variable with drop down list like below.
    01-Current month
    02- Fiscal Year to Date
    03-Project Year to Date
    I have create a new master data for this variable, but it's not working. What I need now is a standalone master data which do not need to link to any exiting records. Can any1 tell me how to create this?

    Just go to the definition of the variable for which you have created a customer exit. There you will find a check box for "Ready for Input". Just tick that checkbox and the variable will be available as a selection variable in the reports selection screen.
    Regards,
    Yogesh

  • How to create an user input variable in SEM-BPS?

    Hi,
    anyone please guide me how to create an user input variable in SEM-BPS? I want to utilized user input variable to udpate characteristic with repost function.
    I tried to create in planning folder, variables right-click create, but the system said 'operation cannot be executed here'...
    please help....
    thanks.

    Hi Bindu,
    would you give me one more help,
    I want to use the variable created for a repost process, how do I achieve that?
    My scenario:
    - There will be a repost function on the planing folder
    - User can select a row or many rows then click the repost function button, then a popup window will appear for user to input the value for the variable
    Is it possible with the scenario? Please advise if I can use standard repost function or should i create a FOX or exit function for this purpose.
    thanks.

  • Need HELP with JTree created by user input

    I have been trying to create code that takes a user input string
    ex: a:b,c;b:g,h,j;g:k,m;b:u
    note: (the above string is then stored into a string array such in the format a:bc;b:ghj;g:km;b:u after it is verified that the hierarchy order is correct)
    The string is read in such that the any value before the : is a parent and its childern continue until a ; is found. Anyway verifying the sting I have accomplished and I have been able to input the string into a modified binary tree as long as there are only 2 childern per parent and graphically represents its structure of hierarchy. The problem is that each parent can have more the two childern.
    I have been working with the BTree class and find its output similar to what I am wanting which would represent a hierarchy of objects (files, employees, etc...) anyway I have been stumped as to how to get the above string into a format that can then create the correct JTree output without hard code.
    If any one has any suggestions on how to turn the data, in the string array into a usable format to create the correct JTree output, I would greatly appreciate it.
    In the above example the string array, a:bc;b:ghj;g:km;b:u would have a desired ouput of
    a
    ..b
    ....g
    ......k
    ......m
    ....h
    ....j
    ....u
    ..c
    Thanks
    Shane

    I have been trying to create code that takes a user input string
    ex: a:b,c;b:g,h,j;g:k,m;b:u
    note: (the above string is then stored into a string array such in the format a:bc;b:ghj;g:km;b:u after it is verified that the hierarchy order is correct)
    The string is read in such that the any value before the : is a parent and its childern continue until a ; is found. Anyway verifying the sting I have accomplished and I have been able to input the string into a modified binary tree as long as there are only 2 childern per parent and graphically represents its structure of hierarchy. The problem is that each parent can have more the two childern.
    I have been working with the BTree class and find its output similar to what I am wanting which would represent a hierarchy of objects (files, employees, etc...) anyway I have been stumped as to how to get the above string into a format that can then create the correct JTree output without hard code.
    If any one has any suggestions on how to turn the data, in the string array into a usable format to create the correct JTree output, I would greatly appreciate it.
    In the above example the string array, a:bc;b:ghj;g:km;b:u would have a desired ouput of
    a
    ..b
    ....g
    ......k
    ......m
    ....h
    ....j
    ....u
    ..c
    Thanks
    Shane

  • Help needed regarding Dynamic Programming

    Hi,
    While doing dynamic programming , we bind the context variable with two types of
    values .
    1 . ddic
    2 . extern
    My doubt is in which case we should use ddic and where to use extern .
    Can anybody help me out regarding this.
    Thanks a lot.

    Hi Ki,
    Predefined, Web Dynpro UI-specific, and user-defined Dictionary types all have the
    prefix ddic:.
    wdContext.getNodeInfo()
    .addAttribute(
    "Visibility",
    "ddic:com.sap.ide.webdynpro.uielementdefinitions.Visbility")
    •&#61472;Logical Dictionary types from Adaptive RFC models have the prefix extern:.
    Check this links
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9214b1e5-0601-0010-fdb0-ec32d43b06e0
    /people/dipankar.saha3/blog/2007/05/31/how-to-create-dynamic-approval-process-using-conditional-loop-block-in-guided-procedure
    Regards,
    Mithu

  • Help with creating a user function

    Hi, I have never created a user function in Oracle and need some help. My function takes in a variable, reads the table looking for a match of the first 2 characters, if not found tries based on the first character. This is what I have so far:
    CREATE function Get_Country_Of_Origin
    (av_SERIAL_ID varchar2)
    RETURN varchar2
    IS
    var_country varchar2;
    BEGIN
    --If match on first 2 characters of serial id return that value
    SELECT DESCRIPTION INTO var_country
    FROM M4LOADER.SUPPLIER_TYPE
    WHERE SUPPLIER_TYPE = LEFT(av_SERIAL_ID,2)
    --Else If match on first character of serial id return that value
    SELECT DESCRIPTION INTO var_country
    FROM M4LOADER.SUPPLIER_TYPE
    WHERE SUPPLIER_TYPE = LEFT(av_SERIAL_ID,1)
    --Else return nothing
    return var_country;
    END;

    <FONT FACE="Arial" size=2 color="2D0000">
    CREATE function Get_Country_Of_Origin (av_SERIAL_ID varchar2)
    RETURN varchar2
    IS
    var_country varchar2;
    BEGIN
    --If match on first 2 characters of serial id return that value
    <font color="#ff8040">Are you sure that the following will return only one single value </font><font color="#800000">( if TO MANY ROWS ARE FOUND then ..?)</font>
    SELECT DESCRIPTION INTO var_country FROM M4LOADER.SUPPLIER_TYPE WHERE SUPPLIER_TYPE = <font color="#0080c0">substr(av_SERIAL_ID,0,2)</font>
    --Else If match on first character of serial id return that value
    <font color="#0d1099">IF var_country is null then</font>
    SELECT DESCRIPTION INTO var_country FROM M4LOADER.SUPPLIER_TYPE WHERE SUPPLIER_TYPE = <font color="#0080c0">substr(av_SERIAL_ID,0,1)</font>
    <font color="#0d1099">End if;</font></font>
    return var_country;
    END;
    -SK
    </FONT>

  • Help Pls: Create New User Form and display custom attributes +++

    Hi All,
    I am trying to create a user screen where a user would see all the organizations he is responsible for and clicking on the organization he would see the certain attribute of all the users that belong to the organization. (Kind of report)
    Account attribute need to be defined with 2 custom attributes:
    1. Organizations Responsible for
    2. Belongs to which organization.
    3. Status
    The first 2 attributes are used to define the organization heirarchy (we can't use the org heirarchy as is in IDM).
    I am just starting on the Sun IDM (very new to the product). Could you please let me know how this could be done? Which form I need to modify and any other changes I need to make.
    Thanks a lot and have a pleasant day,
    Ritesh
    PS: I know this is a long question but i really don't know how to better explain the problem.

    A workaround is to write a PL/SQL procedure to render the custom item (pass in each attribute as a paramter and then use htp.p to print it whatever format you want). You can then disable the default display of attributes (i.e. edit the style so none of the attributes are rendered).
    Hope that helps,
    Mark

  • Help With Homework Reading user input into an Array

    This program is to read questions from a file and retrieve user input as answers.
    This program is no where near complete, but I am stuck. (I dont know why, maybe its too late at night)
    I have a total of three classes. I am currently stuck in my main class. See Comments ("What the hell am I printing/ Will this work?"). In this next line of code, i need to read the question from the file to the user, and then accept their input.
    Main Class:
        public static void main(String[] args) {
            try {
            Scanner in = new Scanner(new FileReader("quiz.txt"));
                catch (Exception e) {
                System.out.println(e);
            ArrayList <Questions> Questions = new ArrayList<Questions>();
            ArrayList<String> answers = new ArrayList<String>();
                  for (Questions qu : Questions)
             System.out.println(); //What the hell am I printing.
             String answer = in.nextLine(); //Will this work?
             answers.add(answer); //This should work
          }Questions Class:
    public class Questions {
        String Questions = "";
        public String getQuestions() {
            return Questions;
        public void setQuestions(String Questions) {
            this.Questions = Questions;
        public Questions(String Questions)
            this.Questions = Questions;
    }answers class:
    package QuizRunner;
    * @author Fern
    public class answers {
        String answers = "";
        public String addAnswers() {
            return answers;
        public answers(String answers) {
            this.answers = answers;
        }

    doremifasollatido wrote:
    According to standard Java coding conventions, class names should start with a capital letter (so, your "answers" should be "Answers"). And, variable and method names should start with a lowercase letter (so, your "Questions" should be "questions").
    And classnames should (almost) never be plural words. So it should probably be an 'Answer' and something else containing a collection of those objects called 'answers'.
    Also, *your variable name should not be the same (case-sensitive match) as your class name.* Although it will compile if done syntactically correctly, it is highly confusing! I first wrote this because you did this for both "Questions" and "answers" classes in their class definition, but you also used "Questions" as your variable name in 'main'. (Note that applying the standard capitalization conventions will prevent you from using the same name for your class name as for your variable name, since they should start with different cases.)
    Of course having an 'Answer' called 'answer' is often fine.
    Your Questions class should probably be called "Question", anyway--it looks like it should hold a single question. And, your "answers" class should probably be called "Answer"--it looks like it should hold a single answer. You aren't using your "answers" class anywhere right now, anyway.Correct. There might be room for a class containing a collection of Question objects, but it's unlikely such a class would contain just that and nothing else.

  • Help needed when dynamically creating new stage sprites

    Morning folks,
    I'm feeling very rusty when asking this question! It feels
    like I should
    know the answer but simply unable to comprehend where I'm
    going wrong at the
    moment!!
    I'm in the process of creating a Director piece that involves
    the user
    having to drag "shapes" onto a pre-defined grid [drag and
    drop style] --
    there are currently three different types of shape that can
    be dragged of
    which many of the shapes can be of the same type. So I need
    to display the
    three shape types on one side of the screen and allow the
    user to drag and
    drop as many as they wish to the girded area.
    I've written the drag and drop routine but now having
    difficulty in
    producing the dynamic creation of a new draggable shape; so
    far I've managed
    to create a new "shape" sprite from my cast library and
    placed it in the
    correct location. Then I create and add a new instance of my
    "Drag and Drop"
    behaviour onto the newly created sprite, but this is where it
    goes wrong --
    although I can drag the dynamically created sprite, once
    dropped Director
    complains of not knowing what its local properties are, for
    example I'm
    unable to reference the locH and locV of the newly created
    sprite!
    I'm really at a loss on this one and would appreciate any
    kind of guidance!
    Many thanks in advance, Mark ;-)

    Hi Saravanan,
    >>>><b>First column - Welcome message , below Date , time and place</b>
       It is possible to add date, time and location in the welcome area. Jus add a table to the <td> of the welcome area container. Like this.
    <% Date d= new Date(); %>
    <TD nowrap class="prtlHdrWelcome" ti="0" tabIndex="0" id="welcome_message"><%=StringUtils.escapeToHTML(GetWelcomeMsg(componentRequest, welcomeClauseStr))%><table width="100"><tr><td nowrap><%=d%></td><td>INDIA</td></tr></table></TD>
    Hope it helps.
    Regards,
    Saravanan
    P.S: Hope you remember the thread
    <a href="http://">https://www.sdn.sap.com/irj/sdn/thread?threadID=152135&messageID=1703666</a>

  • Need help in creating a user exit variable

    Hi all,
    I have created a query in which a key figure needs to be automated with an user exit variable.I want to derive the value of this key figure 'x' based on calender month.
    This key figure should get the cumulative value from the first month of the fiscal year till the calender year month entered while executing the query.
    I got a basic understanding on the User exits from SDN. But Im not sure how to implement this logic.
    I would really appreciate if you could provide me a detailed explanation of how to do this.
    Thanks in advance,
    Vinoth

    Hi
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/208811b0-00b2-2910-c5ac-dd2c7c50c8e8
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6378ef94-0501-0010-19a5-972687ddc9ef
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2d99121a-0e01-0010-e78c-b1ae566a2413
    http://sap.ittoolbox.com/groups/technical-functional/sap-bw/how-can-i-set-bex-variables-in-i_step3-exit_saplrrs0_001-335232

  • Help needed for dynamic update form

    I could really use some advice - I've been asked to build a time tracking application (basically a timesheet) and I have a fair bit done but the part I am really struggling with is the best way to accommodate some of the specifications. I am NOT a programmer (I have some coldfusion experience but nothing really advanced) so I have not managed to sucessfully integrate the various methods I've found on the web so far. The database is created and so are all the queries, and I have also written a cfc to handle the drop-down menu logic needed but I don't really know how to integrate it with the form.
    Our production server has ColdFusion MX7 so all the great functionality in the CF8 examples I can't use.
    The issue is the user should ideally be able to add/edit/delete multiple rows at once- I like CFGRID, and the HTML version seems best. The main issue with the Flash version is the scrolling to get to the insert/delete buttons- I couldn't see how to get rid of that. A separate add and edit form could be ok depending on how easy it is to use.
    One problem I have is that I can't work out how to have default values with the grid (the userID which is a session variable, and the date which is constantly changing- there is a cfcalendar for the user to change date).
    The biggest hurdle is the related select drop-downs I need- it's not quite as simple as the city,state,postcode examples. For the first drop down the pick an option- and for only 2 of those options there is a second drop-down. Anything else and it stops there. For the second drop-down, there are 2 options, and depending on which one of these they pick the 3rd drop-down pulls a query from one or another table in the database (2 entirely different things). The three  options have different database tables. The main timesheet table just stores the id number from those tables (so I also need to display the names on the drop-down from the options tables not the number).
    I played with simple and complicated javascript and coldfusion solutions as well, but because it's a form to update records and also because of the above specs I just couldn't get anything to work right. I tried binding with the cfc and nothing would bind, plus I don't know how to make all happen without a page reload.
    Does anyone have any advice for the best approach to this? As I mentioned I've got tables, queries and even a cfc but I'm not too clear on how to put it all together properly within the constraints of MX7.
    PS I also can't post a lot of code because of where I work- I know that's not helpful but am looking for the best approach to this, then I can work on the details. Right now I am jumping from solution to solution and not getting anywhere.

    Well, a lot of code has come and gone because I couldn't make it work, where I'm currently at is:
    <cfform name="updateform" id="updateform" action="#CurrentPage#?#CGI.QUERY_STRING#">
      <cfgrid name="MainData" height="400" insertbutton="add" deletebutton="remove" query="getMainData" insert="yes" delete="yes" rowheight="20"  selectmode="edit" format="html">
      <cfgridcolumn name="id" display="no">
    <cfgridcolumn name="userID" display="no">
    <cfgridcolumn name="entrydate" display="no">
    <cfgridcolumn name="activityID" >
    <cfgridcolumn name="typeID">
    <cfgridcolumn name="projectID" values="#ValueList(getProjects.id)#" valuesdisplay="#ValueList(getProjects.name)#">
    <cfgridcolumn name="time" width="10">
    <cfgridcolumn name="comment" width="150">
    </cfgrid>
    <cfinput type="hidden" name="entrydate" value="#Session.username#">
    <cfinput type="hidden" name="entrydate" value="#editdate#">
    <cfinput name="update" type="Submit" value="Update">
    </cfform>
    ** for some reason getProjects.name doesn't work and causes an error. I haven't worked out how to get the default inputs for the date and user ID to work either. I also tried binding and a flash form somewhere along the way.
    ** the CFC is below, #ds# didn't work and I had to put in the actual DSN name, not sure why, but anyway this is the logic of the thing. Ideally I would like to use this logic with the cfgrid, but I'm not sure if that is possible? It seems like it would be the most user friendly approach.
    The CFC so far is:
    <cfcomponent>
       <cffunction name="getActivities" access="remote" returnType="query">
            <cfquery name="getActivities" datasource="#ds#">
    SELECT * FROM timesheet_activities
    </cfquery>
            <cfreturn getActivities>
        </cffunction>
        <cffunction name="getTypes" access="remote" returnType="query">
        <cfargument name="Activity" type="any" required="true">
        <cfif ARGUMENTS.Activity EQ "">
            <cfset getType = "">
        <cfelse>
            <cfquery name="getTypes" datasource="#ds#">
            SELECT * FROM timesheet_type
            </cfquery>
        </cfif>
        <cfreturn getTypes>
        </cffunction>
        <cffunction name="GetProjects" access="remote" returnType="query">
        <cfargument name="Activity" type="any" required="true">
        <cfargument name="Type" type="any" required="true">
        <cfif ARGUMENTS.Activity EQ "" OR ARGUMENTS.Type EQ "">
            <cfset LstProjects = "">
        <cfelseif ARGUMENTS.Activity EQ "1" OR "3">
        <cfquery name="getProjects" datasource="#ds#">
    SELECT id,name FROM projectsa
    WHERE completed = 'false'
    </cfquery>
    <cfelse>
    <cfquery name="getEProjects" datasource="#dse#">
    SELECT id,name FROM projectsb
    WHERE statusID = '6'
    </cfquery>
        </cfif>
        <cfreturn getProjects>
        </cffunction>
    </cfcomponent>
    Any attempts to actually use the cfc didn't work. I tried to use it with a normal html update form and got the message- failed to bind, Activity didn't exist. I also tried to bind it to a flash grid. The argument for Activity needs to come from the drop-down Activity type selected. Maybe I'm missing something.
    ETA:
    just moved everything to the live MX7 server (because my dev server is Coldfusion8) and I get the following:
    Attribute validation error for tag CFGRID. The tag does not allow the attribute(s) BINDONLOAD,BIND.
    Does this mean I definitely can't use the CFC with the cfgrid on MX7? Or is there a way to do it?
    Any advice would be greatly appreciated.

  • Help needed on Dynamic XML PDF

    Hello,
    I have an urgent need of help. We had a client requirement to develolp a custom form fillable Flowable template. We used adobe LiveCycle Designer to create a flowable form where fields can be suppressed\expanded to save space. LiveCycle form fields are databinded with the XML Schema at design time. After creating forms, data is prepopulated using the 3rd party ITextsharp for .NET dll using a FillXFA API. Filled PDF document appears fine with the data by adobe reader.
    However, after we try to either convert this form to an Image I don't see DATA in the form and only see the static template. Our requirement is to take the populated PDF and merge it with another static PDF document. I am new to the adobe livecycle forms and needs assistance. I guess the issue is that final populated form is still XML, So If I open this form that is prepopulated with data into LiveCycle I don't see the data and only template, But we can view the populated form fine with data through adobe reader. Even through windows file preview I only see template, but after I open the file through reader I see the data. If through some way we can convert this snapshot (dynamic pdf = populated data with template) to a static pdf or flatten out the dynamic pdf, it will suffice our requirement.We are sort of stuck from past 10 days on this issue. Any help\feedback is greatly appreciated.
    Please let me know if you need any input or examples. Thanks for your time.
    Thank You,
    Himali Vaid

    Harshit Rungta:
    You have opened a number of related questions today. I'd like to see the other ones closed before you continue with this one.
    I'll lock this but will re-open it once the others are marked as solved.
    Rob

  • How to create Variables(User Input Selections) in WEBI Report

    Hi Team,
                  My requirement is to create a WEBI Report on top of BEx query,I have created a Universe and WEBI Report on this Universe but my doubt is How to create Variables for the User to select.The Input selection should be
    User Iputs(All are drop downs)
    Distribution Channel :       ->drop down,user can select one
    Division:                          -> drop down,user can select one
    Department:
    Season:
    Collection:
    Date Format              Valid From:                                 Fiscal Week:
    When the user gives the above selections the output should be displayed as
    Material No   Description     Markdown Week     Reason code1(under this)        Reason code2(under this)   like that for all the
                                                                                valid from         Amount              Valid from          Amount            Reason code.
    I have designed the basic layout of the Report but wanted to know how to design like this,Please help me out in this Format.
    Thanks & Regards,
    Somu

    Hi, depending on the way you set this up (it is not entirely clear if you are talking bex variables or report drop down filters), use the following;
    For BEX variables, the choice will be in the
    UserResponse("prompt message")
    this you can display in the message format you want.
    For drop down filters the choice will be in the DrillFilters(), this one will show all selections in one string.
    However, if you want to format this to a certain message, you need to use the Formula
    DrillFilters([object from drill bar])
    This will give you the result of just that one selection. If the user did not select (yet), the value will be "".
    Hope this helps,
    Marianne

Maybe you are looking for