An XLM Question.. I hope this all right  to ask here? I am new to Java. Thx

Hi to all
I have an xml Question .
I find that if the nodes are not all filled in then i get the error
java.lang.NullPointerException
If all the nodes are filled in it runs fine. Why is this ? Am I missing somthing
Please if you can explane to what I am doing wrong
Thanks
Craig
this is the code to save.
void SavejButton_actionPerformed(ActionEvent e) {
    xmlDoc = new XMLDoc("EPOD_USER");
    try
      Node userConfig =  xmlDoc.addNode(xmlDoc.getRootNode(),"USER_CONFIGURATION");
      //Compant Infomation
      Node  company =xmlDoc.addNode(userConfig,"COMPANY_INFOMATION");
      xmlDoc.addNode(company,"COMPANY_NAME", SetupCompanyNameJText.getText());
      xmlDoc.addNode(company,"COMPANY_TYPE", (String) CompanyTypejComboBox.getSelectedItem());
      //Company Phones
      Node  contact =  xmlDoc.addNode(userConfig,"COMPANY_PHONES");
      xmlDoc.addNode(contact,"PHONE_1", SetupPhWork1jText.getText());
      xmlDoc.addNode(contact,"PHONE_2", SetupPhWork2JText.getText());
      xmlDoc.addNode(contact,"FAX", FaxjTextField.getText());
  xmlDoc.saveToFile("EPOD" +".xml");
    catch (IllegalNodeAddException inae)
      System.out.println(inae.getMessage());
    System.out.println(xmlDoc);
    //  System.out.println(xmlDoc);
  cancel();
  }Code to bring it back .
  public void setUserConfig(){
    xmlDoc = new XMLDoc();
    xmlDoc.loadFromFile("Epod.xml");
    try
      Node company = xmlDoc.getNode("/EPOD_USER/USER_CONFIGURATION/COMPANY_INFOMATION/");
      SetupCompanyNameJText.setText(xmlDoc.getValueOf(company,"COMPANY_NAME"));
      CompanyTypejComboBox.setSelectedItem(xmlDoc.getValueOf(company,"COMPANY_TYPE"));
      Node phone = xmlDoc.getNode("/EPOD_USER/USER_CONFIGURATION/COMPANY_PHONES/");
      SetupPhWork1jText.setText(xmlDoc.getValueOf(phone,"PHONE_1"));
      SetupPhWork2JText.setText(xmlDoc.getValueOf(phone,"PHONE_2"));
      FaxjTextField.setText(xmlDoc.getValueOf(phone,"FAX"));
    catch ( NodeNotFoundException nnfe)
      System.out.println(nnfe.getMessage());

java.lang.NullPointerException
You get a NullPointerException when an object isn't intialized or doesn't contain any data.
When one node isn't filled in the object that was linked to that doesn't get any data and remains un-intilized there for trowing an NullPointerException.
You might wanna change all the "nod.getText()" to like this:
if(SetupCompanyNameJText.getText()!=null) {
xmlDoc.addNode(company,"COMPANY_NAME", SetupCompanyNameJText.getText());
} else {
// some default value
}And do the same with the rest off them...
And to the catch part add change ti to this:
catch (IllegalNodeAddException inae)    {
System.out.println(inae.getMessage());   
} catch(NullPointerExcepton npe) {
System.out.println("NPE: " + npe.getMessage()); 
}That should make it all work =)
By the way this isn't an XML question....

Similar Messages

  • I hope this the right place for reinstall Tiger?

    Hello y'all,
    I cheated and bought an Imac on evilbay! But this has too many freezes and I had trouble migrating stuff so, on advice from another forum here, I have reinstall discs and what is left of a 3 yr support warrantee coming! I was told this thing, most likely, has glithes and crap from former owner!
    It had Firefox in Portugese, I think it wasn't Spanish as spoken in NY, and Dashboard was set to another city, minor crap granted, but I was told to clean up the system and then reinstall OS X but how is my question? Another question, can I save my stuff, from Ipoto, Photo Booth, and Garage Band somewhere? And how do I do that?
    Thanks, Willy

    Hi Again Willy!
    You may find the detailed instructions posted here Formatting, Partitioning Zeroing a Hard Disk Drive, authored by cornelius, helpful.
    ali b

  • Question I hope this will make sense

    okay my question is
    last weekend I formatted my hard drive
    BUT I saved Lightoom on another drive
    I was working on some images in Lightroom, BUT forgot to export those images
    I opened Lightroom in that drive and can see the images, but of course
    Lightroom is saying those images are offline or missing
    is there anyway I can just reconnect those images without spending more time
    going back and working on the same images twice?
    Also the external drive that the images are on and Lightroom are the same drive
    BUT the drive has renamed itself
    thanks
    MT

    Over on the left in the folder panel, right-click on the top level folder that contains your photos and select Update Folder Location

  • Advanced Analysis question..is this the right forum?

    I recently installed advanced analysis on my Pc running Win7 and Office 2010.  I receive an error after refresh which terminates my application.  Can anyone tell me if they have seen an eoor like this before?
    Picture--> 
    http://i.imgur.com/B2Mhi.jpg
    I have the latest patch for BI and AA.

    Hi,
    Can you please confirm that you have Note 1487207 applied?
    Regards,
    Michael

  • Hope this is right Topic Area (Skype headset query)

    Ive got Skype and I know the built in Macbook Microphone works fine - but i feel im always speaking to loud - any suggestions for apple - compatible headset.
    Looked on Amazon - but couldnt find anything that said apple compatible.
    Also short on funds so a budget model is more viable at present
    Thanks in advance

    Have you tried modifying your sound input volume in Apple menu -> System Preferences -> Sound? Speak to your fellow listener and ask them what's too loud for them. They can always diminish their audio volume if it is too loud for them too.

  • I am not sure if this is the right for this the right to ask this.

    My laptop is running well so do I need to upgrade the bios and other up grades                                                           Nikki                                            
    Solved!
    Go to Solution.

    if you dont have any problems no need for updates

  • I recently bought my daughter an iPod 5th generation and quickly set it up with all my info ... E-mail , Apple ID etc. how can I change all of it to her name and new info without losing all her apps , movies and music ???

    I quickly set up my daughters iPod with all my info ( e-mail , Apple ID and password ) how cam I change it all to new info under her name so she can have for her own ??

    You will need to Erase the Device and Set up as New using her Apple ID.
    Then... Sync her content...
    SYNCING with iTunes
    See here  >  http://support.apple.com/kb/HT1386
    Note:
    Anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID
    Apple ID FAQs  >  http://support.apple.com/kb/HT5622

  • Is this the right way - 9i

    I have schema 'A' with few large and many small non-partition tables. I created another schema 'B' identical to 'A' and the only difference was that I partitioned the large tables resulting a combination of partitioned and non partitioned tables in schema 'B'.
    I exported schema 'A' and imported it into 'B'. My question is, IS this the right way or I should done something else.
    Thx

    It would depend on the your goals, but I'd suspect that you would want to create most of the same indexes and views in the new schema. If you're partitioning the tables, though, you would have to give serious thought to how to define the indexes-- should they be global or local, should they be equipartitioned with the underlying tables, etc.-- which exporting and importing wouldn't resolve.
    If the end goal of this exercise is just to produce the same schema with partitioned tables, transition any code & applications to the partitioned schema, and then drop the unpartitioned schema, creating the new schema just adds extra work. Create partitioned tables in the same schema (with slightly different names), load the data, create appropriate indexes, and then ALTER TABLE ... RENAME everything so that the partitioned tables now have the old non-partitioned table names.
    Justin

  • I couldn't even get this one right!

    I need some help with the very basic of java, I cant manage to make the class file...
    I created the file, which i called: "myprog.java" (just followed the instructions from this guide: http://richardbowles.tripod.com/java/guide/intro.htm).
    But then i went into MS-DOS, you know, the little black screen in windows xp :P
    Then typed in as i was instructed "Javac myprog.java" after finding the folder containing the file of course.
    But the all I get is an error message: (this might not be exactly how it is written because I have an norweagon edition of windows XP).
    Javac is not known as an internal or eksternal command, runable (is that a real word?) or "somthing" file.
    I know its not much to go on, beacause of my bad english and, well bad english...
    But if anyone could try and maybe, be able to figure this out i would be very happy.
    Thanks for surviving my lousy english.

    This is not a Java issue. It's a Windows installation/Path/Command prompt issue.
    First, I don't know if the command prompt is case-sensitve or not. If it is, you'll want javac, not Java.
    Second, you'll need to make sure that javac is in your PATH. On XP, in Control Panel --> System on the Advanced tab there's an Envrionment Variables button. Click that, and make sure that the JDK's bin directory is in your Path varaible.
    Usually it will be something like C:\jdk1.5.0\bin, but you'll have to set it for the version and location of your installation.
    You might want to check out the step-by-step instructions here:
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses
    I think it's under "You first cup of Java" or something.

  • HT201250 Hi, I hope this question won't seem too basic but if I want to use a new larger external drive for my time machine backups, will it do a new full backup the first time I plug it in and if so, do I really need all the old backups on my smaller ext

    Hi, I hope this question won't seem too basic but if I want to use a new larger external drive for my time machine backups, will it do a new full backup the first time I plug it in and if so, do I really need all the old backups on my smaller external drive?

    50maz wrote:
    Hi, I hope this question won't seem too basic but if I want to use a new larger external drive for my time machine backups, will it do a new full backup the first time I plug it in
    Yes, it will do a full backup.
    and if so, do I really need all the old backups on my smaller external drive?
    Only if you want to be able to go back in time to those previous Time Machine backups.  When you plug in the new larger external drive, you will only be able to go back as far as the first day you plugged it in and ran the first Time Machine backup on it.

  • Hope this is in the right place...

    ...and apologies if it isn't
    i am hoping to upgrade my 6680 to N93 and junk my iPaq so that i have all my information in one place - but before i do i have one question...
    does the PIM function - notably the calendar and 'to do' - carry more information than on the 6680?
    currently i sync my 6680 with my iMac and it works really well but only takes the headline information, so no notes or details associated with the event or the 'to do'. is this still the case on symbian S60 or will it take more information on sync?
    hope this is clear and thanks in advance for any help.
    cheers

    Do you have the n93? is it out? i can't wait to get my hands on one
    Phones i owned so far 6630,6680,N90,N93*

  • HT5312 can't reset my apple id security question. I follow all the instructions and still I can't reset it. All I get is this We're sorry. The system is unavailable. Please try again

    can't reset my apple id security question. I follow all the instructions and still I can't reset it. All I get is this We’re sorry. The system is unavailable. Please try again

    If you are trying the reset link to your rescue email account and it's not working (Apple may have been doing maintenenace) then have you tried clearing your browser's history and cache and/or trying a different browser ?
    If that doesn't work either then you can try contacting iTunes Support or Apple to get them reset.
    e.g. you can try contacting iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Account Management , and then 'Forgotten Apple ID security questions'
    or try ringing Apple in your country and ask to talk to the Accounts Security Team : http://support.apple.com/kb/HE57

  • Another "2 seconds on 3 off" problem (Hope this is the right place)

    It's kinda hard to figure out what goes where around here, so if this is in the wrong spot, feel free to move it - but please tell me WHERE you moved it to. Thanks.
    The guts:
    MoBo: MSI P55M-GD45
    Processor: Intel I7-860
    Memory: 4x2GB Corsair XMS3
    Graphics card: MSI/R5750-PM2D1G HD5750 R
    Case: Rosewill Smart One
    Power: Rosewill Green 530w continuous
    HD: Seagate Barracuda 7200.12 750GB
    I put this all together the other day, minus the HD (hadn't arrived yet). I started with 2 mems after reading stories about how 4 might not register.
    I started it Saturday, and it lit right up, but I shut it down quickly as it was only a test. This morning, I added my monitor, keyboard and mouse and restarted it. Up came a glorious MSI screen. I rebooted and went into BIOS just to look at the goodies, exiting without changing anything. So far, everything running smoothly.
    I powered down and added the other two memory sticks and - blooie!
    I now have the same problem others have articulated: press the power on and it lights up for a second or two (all fans and leds go on) and then it shuts down. If left on, this repeats and repeats...I stopped it after 15 minutes.
    Cleared the CMOS by the jumper method; nuttin. Tried again using the "take the battery out" method; again, alas, no change.
    So I tore it down to mainboard and CPU, undid and reseated the CPU, added more silver thermal, plugged in the power and...crap. Changed the memory to one stick. Nope. Two sticks; uh-uh. I don't have ready access to another power supply and somehow I don't think that's the problem.
    Is it just me or is this happening more often than it used to? Anyone have any other roads I might travel down

    Sorry, I must have overread the part where you said that the system does not turn on anymore. 
    Quote
    I'm beginning to suspect the board
    That's possible but it is not the only available explanation.
    It could also be a PSU issue or a problem with you video card.  Without further tests, however, all we have are hypotheses that remain to be proved or disproved.
    Quote
    because it's a lot cheaper than the processor.
    Even a 1 million dollar processor is subject to potential damage (sadly).

  • My page has moved to the right of the screen so I do not have a full centre page. How do I move the page back to the centre of the screen. There is no bottom scroll bar for me to move the page to the left of the screen. Hope this makes sense

    The picture on my screen has moved over to the right hand side and I want it to be in the centre. How do I move it back as I do not have a scroll bar at the bottom of the page to do this and am unable to drag it back. Hope this makes sense!

    Its a toolbar thing. I got rid of my Babylon toolbar and it sorted it out!

  • Is this the right forum for SharePoint Online questions?

    Is this the right forum for SharePoint Online questions?

    Hi Edward,
    You could also ask the question in the forum below:
    http://social.technet.microsoft.com/Forums/msonline/en-US/home?forum=onlineservicessharepoint
    Regards,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected] .
    Rebecca Tu
    TechNet Community Support

Maybe you are looking for

  • Component in the BOM whit the for decimal .

    Dear gurus, i need insert in the quantity of component in the BOM the value 1,1234 , a value whit for decimal but the system for the UM ( example KG) is 3 decimal in the  transaction CUNI . Are there the procedure for insert this value ? Thanks a lot

  • How reduce window size?

    I'm using a Mac Pro, OS X 10.7.2, Picasa 3: the window can't be reduced in size and the hatch marks are behind the dock, positioned on the bottom.  How do I make the window smaller?  I've tried moving the dock to the side and still the hatch marks do

  • I have creative cloud photography plan, but cannot update to Lightroom CC

    When i opened Lightroom (part of my CC photography plan) it said to update to Lightroom CC by clicking the adobe app manager thing on the upper bar of my computer (Mac) and clicking "install" next to Lightroom CC. however, next to Lightroom CC it say

  • IBM FileNet-XI-R/3 Integration

    Dear All, Just wanted some help on how do we Integrate FileNet application with R/3 using XI. Any help would be appreciated. Regards, SJ

  • Why won't my macbook pro accept both 4gb Ram, It will only use a 4gb and a 2gb?

    I have a mid 2009 2.6 Ghz 15" macbook pro, and recently purchased two samsund ddr3 4gb 1600hz 204 pin RAM. I removed my two 2gb standard Ram from my macbook pro, and inserted the two 4gb Ram. When I turned the computer one it began using its 3 beep s