Help with JTree data by user input

I am trying to read data into a JTree without it being hardcoded.
An example of the data is:
String data[] = {"a","b","c",";","b","g","h",";","c","t",";","g","u"};
The above data is taken from user input and stored in an array and checked for errors.
I want to somehow read take the above array's data and put it into following format in some kind of loop but I am not sure how.
Object[] hierarchy = {"a", new Object[]{"b",new Object[]{"g","u"},"h"},new Object[]{"c","t"}};
This Object is then passed to a function that interpets it and prints out the appropriate JTREE structure. For the values above it would be:
a
..b
....g
......l
......u
....h
..c
....t
Tha problem is how to take the string array and put that data correctly into the Object array. I have been racking my feeble mind for quite sometime and if any one out there can see it or has a better idea of how to get my data into the JTree please let me know.
Thanks

//OutlookClient.java
//uses also Console class from Bruce Eckel 
//<applet code=OutlookClient width=500 height=300>
//</applet>
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import java.util.*;
import javax.swing.UIManager;
import javax.swing.SwingUtilities;
import BruceEckel.*;
import DynamicTree.*;
import DynamicTreeNode.*;
import java.lang.reflect.*;
/* a class creating a dialog with the version, and other details about the program*/
class AboutDialog extends JDialog {
     private JButton ok = null;
     private Container cp = null;
     private JTextField tname = null;
        public AboutDialog() {
               //System.out.println("constructor");
               ok = new JButton("OK");
               cp = getContentPane();
               cp.setLayout(new FlowLayout());
               JLabel tlab = new JLabel("Outlook - client side");
               cp.add(tlab);
               //tname.setMinimumSize(new Dimension(50,10));
               //tname.setSize(new Dimension(70,10));
               tlab = new JLabel("Author: Jiri Machotka");
               cp.add(tlab);
               tlab = new JLabel("version 1.0 (September 2001)");
               cp.add(tlab);
               tlab = new JLabel("----------------------------------------------");
               cp.add(tlab);
               ok.addActionListener( new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                    dispose();
                  }//actionPerformed
               });//addActionListener
               cp.add(ok);
               setSize(200,150);
               setTitle("About the program");  
               setModal(true);
     }//constructor
  *      <P>This class more-or-less contains a graphic design object used for interaction with a user.</P>
  *     Apart from all ScrollPanes, Buttons, and MenuItems, it contains also 3 interesting members:
  *     <ol>
  *     <li> <I>protected final DefaultMutableTreeNode topNode</I>, which is initialized with
  * a potent, non-removable object of the class <I>Node</I>
  *     <li> <I>protected final DefaultTreeModel treeModel</I>, which is initialized with the <I>topNode</I>
  *     <li> and finally <I>protected final DynamicTree dyn_tree</I>, which uses the 2 objects above
  *     </ol>
  *     <P> The <I>OutlookClient</I> is an applet, but it can be also processed as an application (thanks to
  *     a library by BruceEckel).</P>
public class OutlookClient extends JApplet {
//------------- properties -----------------------------------------
   private Action
        newMail = new AbstractAction ("New Mail", new ImageIcon("images/NewMailIcon.gif")){
          public void actionPerformed(ActionEvent e) {
                     txt.setText("NewMail");
     reply     = new AbstractAction ("Reply", new ImageIcon("images/ReplyIcon.gif")){
          public void actionPerformed(ActionEvent e) {
                     txt.setText("Reply");
   private JButton
     /*b1 = new JButton("Add a Node"),
     b2 = new JButton("Remove the current Node"),*/ //not used now
     tb1 = new JButton (newMail),
     tb2 = new JButton (reply);
   private JTextField
     txt = new JTextField(10);
   private Container
     leftArea = new Container(),
     rightArea = new Container();
   private JScrollPane
        left = new JScrollPane (leftArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS),
        right = new JScrollPane (rightArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
   private JSplitPane
        sp = new JSplitPane (JSplitPane.HORIZONTAL_SPLIT, left, right);
   private JToolBar
     toolBar = new JToolBar();
   private JMenuBar
     menuBar = new JMenuBar();
   /*ActionListener al = new ActionListener() {
     public void actionPerformed(ActionEvent e) {
        String name = ( (JButton)e.getSource()).getText();
        txt.setText(name);
   };*/     //not used now - used as an action listener for buttons b1, b2
   private JMenu
     mainOutlookMenu = new JMenu ("Outlook activities"),
     othersMenu      = new JMenu ("Others"),
     mailMenu     = new JMenu ("Mails"),
     chatMenu     = new JMenu ("Chat"),
     look_and_feelMenu = new JMenu ("Look&Feel");
   private JMenuItem
     closeAppItem     = new JMenuItem ("Exit",KeyEvent.VK_F3),
     newMailItem     = new JMenuItem (newMail),
     replyItem     = new JMenuItem (reply);
   private JRadioButtonMenuItem
     windowsLookAndFeelItem;
   protected final DefaultMutableTreeNode topNode = new DefaultMutableTreeNode(new Node ("Outlook", false, true));
   protected final DefaultTreeModel treeModel = new DefaultTreeModel(topNode);
   protected final DynamicTree dyn_tree = new DynamicTree(topNode, treeModel);
//-------------inner classes----------------------------------------
/** <P>The class <I>MyRenderer</I> sets the renderer of the tree - by doing that icons can be assigned to
   * the tree's nodes. </P>
   * <P> It sould be probably a standard member of a class <I>DynamicTreeWithIcons</I>.</P>
   * <P> However, it uses the knowledge that the class <B>Node</B>, which is the only object that can be
   * found in the dynamic tree in this application, has a method <I>getIcon()</I>, which returns a
   * reference to the icon object assigned to the node.</P>
   * <P><B>This is the only place, where the class Node, or its methods are called explicitely.</B></P>
   protected class MyRenderer extends DefaultTreeCellRenderer {
     /** The constructor of the class.
       * - sets folders icons (opened, closed folder)
     public MyRenderer() {
             //setLeafIcon(new ImageIcon("images/middle.gif")); //for leaves' icon, all at once!
          setOpenIcon(new ImageIcon("images/folder_open.gif"));
          setClosedIcon(new ImageIcon("images/folder_close.gif"));
     /** This overridden method gets the user-specified icon for leaf nodes. */
     public Component getTreeCellRendererComponent(
               JTree tree,
               Object value,
               boolean sel,
               boolean expanded,
               boolean leaf,
               int row,
               boolean hasFocus) {
          super.getTreeCellRendererComponent(tree,value,sel,expanded,leaf,row,hasFocus);
          if (leaf) 
          //workaround: test if icon not eq. null
                 ImageIcon ic = getRightIcon(value);
                 if (ic == null) return this;
                 else
                      setIcon(ic);
          return this;
     }//overridden: getTreeCellRendererComponent
     private ImageIcon getRightIcon(Object value) {
       DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
          try{
          Node node_object = (Node)(node.getUserObject());   
             return (node_object.getIcon());
       catch (Exception e) { return null; }
     }// ImageIcon getRightIcon(Object value)
  }//class MyRenderer
//-------------OutlookClient methods-----------------------------------------
   private void assignListeners(){
     dyn_tree.addTreeSelectionListener(new TreeSelectionListener() {
         public void valueChanged(TreeSelectionEvent e) {
          DefaultMutableTreeNode node = (DefaultMutableTreeNode)dyn_tree.getLastSelectedPathComponent();
          if (node == null) return;
          if (node.isLeaf()) { txt.setText(node.toString()); }
   }//assignListeners()
   private void createLayout(){
     leftArea.setLayout(new BoxLayout(leftArea,BoxLayout.Y_AXIS));
     rightArea.setLayout(new BoxLayout(rightArea,BoxLayout.Y_AXIS));
     //left.setMinimumSize(new Dimension(120,200));
     right.setMinimumSize(new Dimension(50,50));
     //rightArea.add(b1);
     //rightArea.add(b2);
     rightArea.add(txt);
     //leftArea.add(tree);  ... not nice (why?)
       left = new JScrollPane (dyn_tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);       
     left.setMinimumSize(new Dimension(180,200));
     sp.setLeftComponent(left);
   }//createLayout()
   private void createMenu(){
     ButtonGroup group = new ButtonGroup();
        JRadioButtonMenuItem rbMenuItem;
     closeAppItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, ActionEvent.ALT_MASK));
     closeAppItem.getAccessibleContext().setAccessibleDescription("Closes application");
     closeAppItem.addActionListener( new ActionListener() {
          public void actionPerformed(ActionEvent e) {System.exit(0);}
     othersMenu.setMnemonic(KeyEvent.VK_O);
     othersMenu.getAccessibleContext().setAccessibleDescription("System settings&Others");
        rbMenuItem = new JRadioButtonMenuItem("Java");
        rbMenuItem.setSelected(true);
        rbMenuItem.setMnemonic(KeyEvent.VK_J);
        group.add(rbMenuItem);
        rbMenuItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {setPLAF(UIManager.getCrossPlatformLookAndFeelClassName( ) );}
        look_and_feelMenu.add(rbMenuItem);
        rbMenuItem = new JRadioButtonMenuItem("Windows");
        rbMenuItem.setMnemonic(KeyEvent.VK_W);
        group.add(rbMenuItem);
        rbMenuItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {setPLAF("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");}
        look_and_feelMenu.add(rbMenuItem);
     windowsLookAndFeelItem = rbMenuItem;
     look_and_feelMenu.setMnemonic(KeyEvent.VK_L);
     look_and_feelMenu.getAccessibleContext().setAccessibleDescription("Look&Feel");
     JMenuItem aboutItem = new JMenuItem ("About");
     aboutItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
               AboutDialog ad = new AboutDialog();
               ad.show();
     othersMenu.add(look_and_feelMenu);
     othersMenu.addSeparator();
     othersMenu.add(aboutItem);
     othersMenu.addSeparator();
     othersMenu.add(closeAppItem);
     mainOutlookMenu.setMnemonic(KeyEvent.VK_A);
     mainOutlookMenu.getAccessibleContext().setAccessibleDescription("Outlook activities");
     menuBar.add(mainOutlookMenu);
     menuBar.add(othersMenu);
     mailMenu.setMnemonic(KeyEvent.VK_M);
     mailMenu.getAccessibleContext().setAccessibleDescription("Mail activities");
     chatMenu.setMnemonic(KeyEvent.VK_C);
     chatMenu.getAccessibleContext().setAccessibleDescription("Chat");
     chatMenu.setEnabled(false);
     mainOutlookMenu.add(mailMenu);
     mainOutlookMenu.addSeparator();
     mainOutlookMenu.add(chatMenu);
     //mailMenu.add(newMail);
     //mailMenu.add(reply);     //class Action has problems to catch the accelerator keys
     newMailItem.setMnemonic(KeyEvent.VK_N);
     replyItem.setMnemonic(KeyEvent.VK_R);
     mailMenu.add(newMailItem);
     mailMenu.add(replyItem);
     newMailItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
     replyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK));
     //newMail.putValue(Action.NAME, "New mail");
     //newMail.putValue(Action.SHORT_DESCRIPTION, "New mail");
     //newMail.putValue(Action.LONG_DESCRIPTION, "New mail");
     //newMail.putValue(Action.MNEMONIC_KEY, "N");  //cast an exception. why?
     //newMail.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));     
     setJMenuBar(menuBar);
   }//createMenu()
   private void createToolBar(){
     //toolBar.add(newMail);
     //toolBar.add(reply);    //does not provide texts and mnemonics
     tb1.setMnemonic(KeyEvent.VK_N);
     tb2.setMnemonic(KeyEvent.VK_R);
     toolBar.add(tb1);
     toolBar.add(tb2);
   }//createToolBar()
   private void createNodes(DefaultMutableTreeNode topNode){
     //new for dynamic processing
     DefaultMutableTreeNode
          parentNode = null,
          leaveNode  = null;
     parentNode = dyn_tree.addObject(null,new Node ("MailFolders", false, true));
     dyn_tree.addObject(parentNode,new Node ("Inbox","images/InboxIcon.gif", false, false));
     dyn_tree.addObject(parentNode,new Node ("Outbox","images/OutboxIcon.gif", false, false));
     dyn_tree.addObject(parentNode,new Node ("Sent","images/SentIcon.gif", false, false));
     dyn_tree.addObject(parentNode,new Node ("Deleted","images/DeletedIcon.gif", false, false));
     //leaveNode.setEnabled(false);  //TODO: disable "Chat"node
     dyn_tree.addObject(null,new Node ("Chat", false, false));
   }//createcreateNodes(DefaultMutableTreeNode)
   private void setTreeSettings(){
     //one selection at one time
     dyn_tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
     //connect nodes with a thin line - Java style only
     dyn_tree.putClientProperty("JTree.lineStyle","Angled");
     //collapse the root's children first
     //tree.setShowsRootHandles(false);
     //icon adjustment
     MyRenderer MyRen = new MyRenderer();
     dyn_tree.setCellRenderer(MyRen);
     //modifiable tree - by double click - allows modifying of nodes' names
     // but unfortunately also restores original icons
     //tree.setEditable(true);
   }//setTreeSettings()
   private boolean setPLAF(String LookAndFeelName){
      try{
     UIManager.setLookAndFeel(LookAndFeelName);
     SwingUtilities.updateComponentTreeUI(this);
     return true;
      } catch (Exception e) {
     //e.printStackTrace(System.err);
     return false;
   }//setPLAF(String LookAndFeelName)
   private void trytosetLookAndFeel(){
      if (setPLAF("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"))
          windowsLookAndFeelItem.setSelected(true);
   }//trytosetLookAndFeel()
   /** The applet's <I>init()</I>.
     * Calls methods to construct all visible objects.
     * Apart from that it also assigns the renderer to the tree.
   public void init(){
     sp.setOneTouchExpandable(true);
        //sp.setDividerLocation(150); - system puts the value to optimize the left part
     sp.setPreferredSize(new Dimension(450,200));
     Container cp = getContentPane();
     cp.setLayout(new FlowLayout());
        createLayout();     
     createMenu();
     createToolBar();
     createNodes(topNode);
     setTreeSettings();
     //createPopupMenu();
     assignListeners();
     cp.add(toolBar);
     cp.add(sp);
     trytosetLookAndFeel();
   }//init()
   /** If called as an application.
     * The desired Windows Look&Feel is re-set again, when the applet is running. Otherwise, it in an application
     * it tends not to work correctly.
   public static void main(String[] args) {
     OutlookClient theApplet;
     BruceEckel.Console.run(theApplet=new OutlookClient(), 500, 300);
     theApplet.trytosetLookAndFeel();
   }//main(String[])
}///:~Take a look namely at createNodes
Hope it helps.

Similar Messages

  • 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 with JAVA StringObject - & assign user input; StringMethod

    Hi Everyone! I need help with this Java Program, I need to write a program, single class, & file. That will prompt the user to enter a word. The output will be separted by hypens and do this until the user enters exit. I think this is done by using a string variable. Then use the length of the word to setup a loop to print each letter out with hypens. (example c-a-t)
    1. I think I should store the word like this: Word.Method(). Not sure of this the API was confusing for me because I wasn't sure of what to do.
    2. A string method to find out how many letters are in the user's word in order to setup a loop to print each letter out. I think I can use a While loop to accomplish this?
    3. A string method to access each letter in a string object individually in order to print individual letters to the screen with those hypens. This is really confusing for me? Can this be accomplished in the While loop? or do I declare variables in the main method.
    Any examples you can refer me to would be greatly appreciated. Thanks

    Getting user input:
    This may look strange to a newbie but there's nothing much you can do since you wanted a single class file:import java.io.*
    public class InputTest {
       public static void main(String[] args) {
          BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
          System.out.println("Hi! Please type a word and press enter.");
          String lineReadFromUser = in.readLine();
          System.out.println("You typed " + lineReadFromUser);
    }You can get the lenght of a String using the length() method. Example: int len = "Foobar".length();
    You can get the individual characters of a String with the charAt() method. Example: char firstCharOfString = string.charAt(0);
    (remember that the argument must be from 0 to length-1)
    You can access the documentation of all classes, including java.lang.String, at http://java.sun.com/j2se/1.3/docs/api/index.html You can also download the docs.

  • Need help with Java app for user input 5 numbers, remove dups, etc.

    I'm new to Java (only a few weeks under my belt) and struggling with an application. The project is to write an app that inputs 5 numbers between 10 and 100, not allowing duplicates, and displaying each correct number entered, using the smallest possible array to solve the problem. Output example:
    Please enter a number: 45
    Number stored.
    45
    Please enter a number: 54
    Number stored.
    45 54
    Please enter a number: 33
    Number stored.
    45 54 33
    etc.
    I've been working on this project for days, re-read the book chapter multiple times (unfortunately, the book doesn't have this type of problem as an example to steer you in the relatively general direction) and am proud that I've gotten this far. My problems are 1) I can only get one item number to input rather than a running list of the 5 values, 2) I can't figure out how to check for duplicate numbers. Any help is appreciated.
    My code is as follows:
    import java.util.Scanner; // program uses class Scanner
    public class Array
         public static void main( String args[] )
          // create Scanner to obtain input from command window
              Scanner input = new Scanner( System.in);
          // declare variables
             int array[] = new int[ 5 ]; // declare array named array
             int inputNumbers = 0; // numbers entered
          while( inputNumbers < array.length )
              // prompt for user to input a number
                System.out.print( "Please enter a number: " );
                      int numberInput = input.nextInt();
              // validate the input
                 if (numberInput >=10 && numberInput <=100)
                       System.out.println("Number stored.");
                     else
                       System.out.println("Invalid number.  Please enter a number within range.");
              // checks to see if this number already exists
                    boolean number = false;
              // display array values
              for ( int counter = 0; counter < array.length; counter++ )
                 array[ counter ] = numberInput;
              // display array values
                 System.out.printf( "%d\n", array[ inputNumbers ] );
                   // increment number of entered numbers
                inputNumbers++;
    } // end close Array

    Yikes, there is a much better way to go about this that is probably within what you have already learned, but since you are a student and this is how you started, let's just concentrate on fixing what you got.
    First, as already noted by another poster, your formatting is really bad. Formatting is really important because it makes the code much more readable for you and anyone who comes along to help you or use your code. And I second that posters comment that brackets should always be used, especially for beginner programmers. Unfortunately beginner programmers often get stuck thinking that less lines of code equals better program, this is not true; even though better programmers often use far less lines of code.
                             // validate the input
       if (numberInput >=10 && numberInput <=100)
              System.out.println("Number stored.");
      else
                   System.out.println("Invalid number.  Please enter a number within range."); Note the above as you have it.
                         // validate the input
                         if (numberInput >=10 && numberInput <=100)
                              System.out.println("Number stored.");
                         else
                              System.out.println("Invalid number.  Please enter a number within range."); Note how much more readable just correct indentation makes.
                         // validate the input
                         if (numberInput >=10 && numberInput <=100) {
                              System.out.println("Number stored.");
                         else {
                              System.out.println("Invalid number.  Please enter a number within range.");
                         } Note how it should be coded for a beginner coder.
    Now that it is readable, exam your code and think about what you are doing here. Do you really want to print "Number Stored" before you checked to ensure it is not a dupe? That could lead to some really confused and frustrated users, and since the main user of your program will be your teacher, that could be unhealthy for your GPA.
    Since I am not here to do your homework for you, I will just give you some advice, you only need one if statement to do this correctly, you must drop the else and fix the if. I tell you this, because as a former educator i know the first thing running through beginners minds in this situation is to just make the if statement empty, but this is a big no no and even if you do trick it into working your teacher will not be fooled nor impressed and again your GPA will suffer.
    As for the rest, you do need a for loop inside your while loop, but not where or how you have it. Inside the while loop the for loop should be used for checking for dupes, not for overwriting every entry in the array as you currently have it set up to do. And certainly not for printing every element of the array each time a new element is added as your comments lead me to suspect you were trying to do, that would get real annoying really fast again resulting in abuse of your GPA. Printing the array should be in its own for loop after the while loop, or even better in its own method.
    As for how to check for dupes, well, you obviously at least somewhat understand loops and if statements, thus you have all the tools needed, so where is the problem?
    JSG

  • "To Do" items with deadline dates as an input to iCal

    I like the list of To Do's on the left hand side of the iCal window, but it would be more useful if the To Do items with specific due dates would show up in the calendar on the date the To Do is due to be completed.
    Is there a way for the To Do items with due dates to automatically be posted directly into the calendar on the dates the items are due for completion? If so, how do I do that?
    Appreciate any help or guidance on the organizing of To Do items in general.

    AllegroMac wrote:
    I like the list of To Do's on the left hand side of the iCal window, but it would be more useful if the To Do items with specific due dates would show up in the calendar on the date the To Do is due to be completed.
    Is there a way for the To Do items with due dates to automatically be posted directly into the calendar on the dates the items are due for completion?
    no, there is no way to do that. what you can do is set up alarms for your to dos that send you an email or display a popup around the time they are due.

  • Need help with saving data and keeping table history for one BP

    Hi all
    I need help with this one ,
    Scenario:
    When adding a new vendor on the system the vendor is suppose to have a tax clearance certificate and it has an expiry date, so after the certificate has expired a new one is submitted by the vendor.
    So i need to know how to have SBO fullfil this requirement ?
    Hope it's clear .
    Thanks
    Bongani

    Hi
    I don't have a problem with the query that I know I've got to write , the problem is saving the tax clearance certificate and along side it , its the expiry date.
    I'm using South African localization.
    Thanks

  • Need help with Rollback data if there is error in Data load

    Hi All,
    We are trying to load data to Oracle 11g database. We want a trigger, procedure or something like that to rollback the data if there are errors in load. Is it possible to do rollback after all the records has been parsed ? So if we try to load 100 records and if there are 30 records with error, we want to rollback after all the 100 records are parsed.
    Please advice.

    >
    Thanks for the suggestion. I'll try that option. So currently we are only loading data that is validated and erroneous records are rejected using trigger. So we don't get any invalid data in table. But Now users are saying that all the records should be rejected if there is even one error in the data load.
    >
    I generally use a much simpler solution for such multi-stage ETL processes.
    Each table has a IS_VALID column that defaults to 'N'. Each step of the process only pulls data with the flag set to 'Y'.
    That allows me to leave data in the table but guarantee that it won't be processed by subsequent stages. Since most queries that move data from one stage to another ultimately have to read table rows (i.e. they can't just use indexes) it is not a performance issue to add a predicate such as "'AND IS_VALID = 'Y'" to the query that accesses data.
    1. add new unvalidated data - automatically flagged an invalid by default of 'N" on IS_VALID column
    2. run audit step #1 - capture the primary key/rowid of any row failing the audit.
    3. run audit steps #2 through #n - capture error row ids
    4. Final step - update the data setting IS_VALID to 'Y' only if a row passes ALL audits: that is, only if there are NO fatal errors for that row captured in the error table.
    That process also allows me to capture every single problem that any row has so that I can produce reports for the business users that show everything that is wrong with the data. There are some problems that the business wan't to ignore, others that can be fixed in the staging tables then reprocessed and others that are rejected since they must be fixed in the source system and that can take several days.
    For data that can be fixed in the staging tables the data is fixed and then the audit is rerun which will set the IS_VALID flag to 'Y' allowing those 'fixed' rows to be included in the data that feeds the next processing stage.

  • Help with a Date variable

    I'm creating a jscript to automatically rename a file the current days date, but i can't figure out how to get it to put a zero in front of days/months that are single digits. Can anyone help me real quick? Heres the code i already have, pay no attention to the "dh" part, it has to be there:
    var todayFileName = "dh" +
    today.getFullYear() + "" +
    today.getMonth() + "" +
    (today.getDate()+1); + " " +

    This little javascript function should help.
    Note that it is only meant to work with valid dates. Putting in a -7 for the parameter will result in something not so nice :-)
    function twoDigitNo(no){
        return  (no < 10) ? "0" + no : no;
      }Cheers,
    evnafets

  • Help with calender dates

    Hello every one
    I have a table with calender dates and there is a indicator which says if it is a working day or an holiday. Is there a way I can write a procedure that will help me fill that indicator column based on the calender dates.
    My table looks something like this
    date indicator
    01/01/2011 Holiday
    01/02/2011 working day
    01/03/2011 working day
    12/31/2011 working day

    Good Friday or Easter Monday as a holiday I can't help you with that.
    here is easter both julian and gregarian
    WITH years AS (    SELECT 1989 + LEVEL yr
                         FROM DUAL
                   CONNECT BY LEVEL <= 30)
    SELECT TO_CHAR (TO_DATE (day || ' ' || month || ' ' || yr, 'DD MM YYYY'),
                    'DD MON YYYY')
              easter_day_julian,
           TO_CHAR (
              TO_DATE (day || ' ' || month || ' ' || yr, 'DD MM YYYY') + 13,
              'DD MON YYYY')
              easter_day_gregorian
      FROM (SELECT yr,
                   a,
                   b,
                   c,
                   d,
                   e,
                   FLOOR ( (d + e + 114) / 31) month,
                   MOD (d + e + 114, 31) + 1 day
              FROM (SELECT yr,
                           a,
                           b,
                           c,
                           d,
                           MOD ( ( (2 * a) + (4 * b) - d + 34), 7) e
                      FROM (SELECT yr,
                                   a,
                                   b,
                                   c,
                                   MOD ( (19 * c + 15), 30) d
                              FROM (SELECT yr,
                                           MOD (yr, 4) a,
                                           MOD (yr, 7) b,
                                           MOD (yr, 19) c
                                      FROM years))))Edited by: pollywog on Nov 24, 2010 2:06 PM

  • Need help with enhanced data source in Production system

    Hello Gurus,
    1.                  I enhanced a datasource in BW and populated the field using customer exit using CMOD function. In Dev system, i dont have much data, so I deleted the whole data and did full load.
    what shud I do in Production side, so that Delta wudnt be affected??since in production, we have millions of records, we wont do full load., what is the best way to populate the field in production after transporting the datasource to production without disturbing delta's, to reflect the new field for previous years data???
    2.  can we put 0customer and 0material in the same dimension?? how its going to affect the performance?
    Thanks in advance.,
    Best Regards,
    Pavan

    Hi,
    Please see this
    1.
    see this thread
    populated the new field with historic data
    2. can we put 0customer and 0material in the same dimension?? how its going to affect the performance?
    Its better not to use them in a single dimension  because one customer and take more than one material so if you have 100 customer and 1000 materials  this combination will generate a large number of records. Its always better to keep characteristic which are having 1:N relation ship in one dimensional in you  case customer and material will have an M:N type of relationship.which will result in slow performance.
    Regards,
    Ravi

  • Need help with re-prompting the user for input .

    I am trying to wright a code the re prompts the user for input if they enter anything but an integer but I keep getting a "char cannot be dereferenced" error when I try to compile.
    Here's what I have got:
    import java.util.Scanner; // imports Scanner methods
    public class SandBox
      public static void main(String[] args)
          // re-prompting test
          Scanner in = new Scanner(System.in);
          System.out.println("Please enter an integer: ");
          String i = in.nextLine();
          for(int a=0; a<i.length(); a++)
              if( (i.charAt(a).isDigit()) ) {
                  System.out.println("Thank you!");
                  break;
                } else {
                    System.out.println("Please try again");
                    continue;
          int b = Interger.parseInt(i);
      }// end of class
    }//end of main method
     

    Sorry for double posting but it won't let edit my last post.
    I would prefer to go through it without using try catch because it takes longer though I will use it if I cannot get the other way working. I currently have two versions of the code both using try catch and the other way but both say that they "cannot find symbol" when I try to parse. here are both versions of the code:
    import java.util.Scanner; // imports Scanner methods
    public class SandBox
      public static void main(String[] args)
          // try catch test
          boolean inputIsFaulty = true;
          int inputInt = 0;
          Scanner in = new Scanner(System.in);
          do {
             System.out.println("Please enter an integer: ");
             String i = in.nextLine();
             for(int a=0; a<i.length(); a++)
                if (Character.isDigit(i.charAt(a))) {
                  System.out.println("Thank you!");
                  inputIsFaulty = false;
                } else {
                    System.out.println("Please try again");
            while (inputIsFaulty);
          inputInt = Integer.parseInt(i);
      }//end of class
    }//end of main method
    import java.util.Scanner; // imports Scanner methods
    public class SandBox2
      public static void main(String[] args)
          // try catch test
          boolean inputNotOK = true;
          int inputInt = 0;
          Scanner in = new Scanner(System.in);
          do {
             System.out.print("Please enter an integer: ");
             String inputStr = in.nextLine();
             try {
                inputInt = Integer.parseInt(inputStr);
                // this line is only reached if the parse works
                inputNotOK = false;
             catch (NumberFormatException e) {
                System.out.println("You didn't enter a proper number.  Please Try again.");
          while (inputNotOK);
          inputInt = Integer.parseInt(imputStr);
      }//end of class
    }//end of main method
     

  • Help with inserting Date into MySQL DB from registration form input

    I'm trying to automatically input the registration date of a customer into my MySQL DB. Nothing seems to work. I've tried timestamp in a table field, I've tried a hidden field in the form. Any suggestions?

    You can use NOW() in the insertion record code, it will display like a time stamp format (date + time). Otherwise u can use this if u just want to store the date, $today = date("j F Y "); . It will display like 21 May 2009. Further information about date() function you can get it HERE.

  • Help with POST data if  multiple selections are chosen

    I've created a form with a menu (list) that includes all 50
    states. I'm using the POST option, along with PHP, to process the
    form data, which will be emailed to me. The list-menu looks like
    this:
    http://askdave.info/help/states_menu.gif
    and I have "Allow Multiple Selections" checked in the Property
    Inspector.
    If the user chooses multiple states, I want
    EACH of those states to be listed in the email that I
    receive. Right now, if I check multiple states, I only get
    the very last state that's selected. For example, here's the
    email I get after I check 5 different states.
    http://askdave.info/help/formdata.gif
    Problem--> In this email, only one state is listed
    (Hawaii) even though I selected 5 different states. How do I get
    the form data to list ALL states that are checked?
    Here is what I have:
    <form name="form1" method="post" action="process.php">
    <input type="hidden" name="required"
    value="name,phone,email,states,capital" />
    And then for the menu that lists the states, I have:
    <label>
    <select name="states" size="7" multiple id="states">
    <option>All States</option>
    <option>Alabama</option>
    <option>Alaska</option>
    <option>Arizona</option>
    <option>Arkansas</option>
    and so on...
    What am I missing? How do I get the PHP script to send
    multiple values, if multiple values are chosen? (I'm new to PHP, so
    go easy on me. I can post my code, if necessary.) Is this a PHP
    issue, or do I need to add something to the HTML form?

    Hi,
    >>
    I think DynaForm stands for Dynamic Form
    >>
    this makes some sense ;-) I was just wondering because there
    is a pre-made script called DynaForm
    here, but
    it has a different "logistics" than yours.
    However, both "DynaForm" versions are pretty basic, as they
    just deal with non-multiple values - form fields like single line
    input fields, texareas and non-multiple select´s. Your script
    e.g. just loops through all existing form fields using the
    "foreach" method:
    //Pulls form fields & values.
    foreach ($this->post as $field => $value) { // looping
    through all form fields
    if ( $field == 'required' ) continue;
    $this->_addLine($field, $value); // here´s where the
    field´s name/value consolidation happens
    ...and simply consolidates a field´s "value" with its
    associated "name". The problem is : this method just works for
    fields having just 1 value -- but any "multiple value" form fields
    (e.g. your "states" select or checkbox groups which can pass
    multiple values as well) actually require a separate "foreach"
    treatment within the script, and this hasn´t been incorporated
    here.
    That said, I suggest using an other pre-made solution like
    PHP
    Form Mail script that´s capable to handle your multiple
    values - scenario innately.

  • Help with Inconsistent data from NI6211

    I'm not getting very far with establishing good data transfer from an NI 6211 and don't seem to be able to pin point the issue or get confidence from DasyLab V10 to be able to look for the problem in another area.
    The NI6211 is set for period measurement and automatically uses a low frequency counter with sample on demand. The measurement range is set for 200ms to 1ms
    The Dasylab Counter Input task displays the sample on demand and block size of "1".
    I have also selected "10" as an output after timeout of 5seconds.
    I have set the module to use the Dasylab timebase and have configured all 3 timebases for 1000Hz and (tried higher and lower values) and set block sizes to 1.
    Whenever I change the timebase setting I always carry out a synchronise with MAX.
    I have been writing to a file using time deducted from data.
    With these settings I have the value "10" generated and stored in the file.
    When it says "Output after timeout (s) of:", does this mean that their has been no communication for 5seconds even though I can get time stamp information indicating only a few milliseconds have passed?
    Does time deducted information mean time deduced information (ie. time stamp from the data)
    Is there anything I need to do with A/D window? I have changed the sampling rate in there but it only appears to change the driver setting.
    Any help much appreciated.
    Thanks
    Mark..

    Additional to information in above post, the operating system is Windows Vista Home Premium with Service Pack 1.
    Could this be the underlying issue, Dasylab and Windows Vista are untested?
    Thanks

  • Need help with converting date format to decimal in SSRS expression.

    Hi all,
    I have a decimal data type column with a record in the following format 20150219 --> yyyyMMdd. And I am trying to convert the return value from SSRS date/time parameter to a decimal value.
    The TMDTOP column is the decimal data type with date records in yyyyMMdd format.
    My return parameter is the following:
    =IIf(IsNothing(Parameters!SystemDate.Value),Fields!TMDTSY.Value,CDec(Format(Parameters!SystemDate.Value,"yyyyMMdd"))) 
    When I try to run the report I get the following error:
    Failed to evaluate the FilterValue of the DataSet ‘DataSet1’. (rsFilterEvaluationError)
    I appreciate if anyone can help me on solving this problem.
    Thanks in advance.

    why casting date to decimal here? Can you explain?
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

Maybe you are looking for