How to write settings into xml

I?ve got a small class that returns the names of each JInternalFrame. The code is below; I have an xml file where I am saving various settings. In the xml file I have created a tag and in that tag I want to write all the name of the JInternalFrames. Can someone help me with writing a method which will write the frames names into the xml tag.
package persisted_display_settings;
import javax.swing.*;
import mdi_internal_frame.FrameManager;
import mdi_internal_frame.TSFrame;
import state_manager.StateManager.Prerequisite;
* The PersistDisplaySettings looks after the persisted screen settings for each frame.
* It allows the user to save the layout settings of each screen so that the user doesn't
* have to reconfigure layout every time they restart
public class PersistDisplaySettings {
     * Gets the name of all TS frames and the last modified layout information and saves
     * this in a xml file
     * @param projectDir is the project directory
     public void SaveCurrentTsProfile(String projectDir) {
          System.out.println("Start Here");
          System.out.println(projectDir);
          JInternalFrame[] frames = FrameManager.getJDesktopTS().getAllFrames();
          System.out.println(frames.length);
// Iterate through each frame that is open and get the names
          // Only get the names of the frames that are saved
          for (int noOfFrames = 0; noOfFrames < frames.length; noOfFrames++) {
               String tsName = "";
               boolean unsaved = true;
               //Check to make sure the frames are TS frames
               if (frames[noOfFrames] instanceof TSFrame) {        
                    JInternalFrame tsFrames = frames[noOfFrames];
                    if(tsFrames.getTitle().contains(":-")){
                         tsName = tsFrames.getTitle();
                         tsName = tsName.substring(17);
                         unsaved = getSavedTSNames(tsFrames);
                    else if(tsFrames.getTitle().contains("-")){
                         tsName = tsFrames.getTitle();
                         tsName = tsName.substring(16);
                         unsaved = getSavedTSNames(tsFrames);
                    if(!unsaved){
                         System.out.println(tsName);
          System.out.println("point 2");
          FrameManager.getSelectedTSFrame().isMaximum();
          System.out.println(FrameManager.getSelectedTSFrame());
          System.out.println(FrameManager.getSelectedTSFrame().isMaximum());
     * Returns all the saved TS frame names. This method is Called
     * by the SaveCurrentTsProfile method
     * @param save boolean flgg indicating if GUI should save modified test sequences
     public boolean getSavedTSNames(JInternalFrame frame) {
                    boolean[] modified = ((TSFrame)frame).stateManager
                    .getPrereqState(Prerequisite.TS_MODIFIED);
                    return modified[0];     
}

I have a GUI project which has frames consisting of data in table view. What i'm trying to do is save the layout of the frames into an xml file so that the user doesn't have to reconfigure layout every time they restart the application. The code which i have attached gets the names of each frame.
I also have another class which is currently generating various other settings and writing it into the xml file. The xml file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
- <PTMViewProfile>
- <viewProfile>
<testSequences />
- <tsName>
<tsName tag="arefa" />
</tsName>
<tsStatus />
- <columns>
- <tcc>
<column tag="usim" visible="false" width="75" index="-1" />
<column tag="dev" visible="false" width="75" index="-1" />
<column tag="tp" visible="false" width="75" index="-1" />
<column tag="iwd" visible="false" width="75" index="-1" />
<column tag="tdma" visible="false" width="75" index="-1" />
<column tag="selref" visible="true" width="75" index="2" />
<column tag="md" visible="false" width="75" index="-1" />
<column tag="timer" visible="false" width="75" index="-1" />
<column tag="description" visible="false" width="75" index="-1" />
<column tag="name" visible="true" width="120" index="0" />
<column tag="domain" visible="true" width="75" index="5" />
<column tag="note" visible="false" width="75" index="-1" />
<column tag="hsdpa" visible="false" width="75" index="-1" />
<column tag="wi" visible="true" width="75" index="4" />
<column tag="ttcn" visible="false" width="75" index="-1" />
<column tag="approval" visible="false" width="75" index="-1" />
<column tag="inter" visible="false" width="75" index="-1" />
<column tag="duration" visible="false" width="75" index="-1" />
<column tag="etsi" visible="true" width="75" index="1" />
<column tag="hsupa" visible="false" width="75" index="-1" />
<column tag="auto" visible="true" width="75" index="3" />
<column tag="cipher" visible="false" width="75" index="-1" />
<column tag="suite" visible="false" width="75" index="-1" />
<column tag="shield" visible="false" width="75" index="-1" />
<column tag="hop" visible="false" width="75" index="-1" />
</tcc>
In the - <tsName> i want to print out all the names of the frames.
This is the method thats creating the tags in the xml file. This method is stored in a different class;
public Element writeViewProfile(String name) {
          Message.logInfo("Saving View Profile XML Document:" + name);
          Element root = XMLManager.createNamedElement("PTMViewProfile");
          Element viewProfile = XMLManager.createNamedChildElement(root, xmlViewTag);
          Element tsNameTag = XMLManager.createNamedChildElement(viewProfile, xmlTSFrameTag);
          Element tsFrameName = XMLManager.createNamedChildElement(viewProfile, xmlFrameTag);
          writeTsFrame(tsFrameName, "Arefa");
          Element tsFrameStatus = XMLManager.createNamedChildElement(viewProfile, xmlFrameStatusTag);
          Element columns = XMLManager.createNamedChildElement(viewProfile, xmlColumnsTag);
          writeColumnSet(columns, xmlTCCColumnTag);
          writeColumnSet(columns, xmlTSColumnTag);
          writeColumnSet(columns, xmlResTCCColumnTag);
          writeColumnSet(columns, xmlResTSColumnTag);
          Element sashes = XMLManager.createNamedChildElement(viewProfile, xmlSashesTag);
          for (int i = 0; i < sashList.size(); i++) {
               writeSash(sashes, sashList.get(i));
          return root;
     };This is the method thats writing the xml file;
private void saveProfile(String name) {
          if (!readyToSave)
               return;
          ViewProfile viewProfile = viewProfiles.get(currentViewProfileName);
          if (viewProfile != null) {
               // try {
               Element root = viewProfile.writeViewProfile("ptmProfile");
               // create an xml document with our data
               Document doc = new Document(root);
               // dump the document to file
               XMLManager.dumpXMLDocToFile(doc, "ptmProfile", FileManager.baseDir());
               // catch (Exception ignore) {
               // System.out.println(ignore.getMessage() + ignore.getStackTrace());
     }In the xml file how can i print the names of the frames into that <tsName> tag using the SaveCurrentTsProfile() method .
I hope this helps you understand whats hapenning.
Thanks!

Similar Messages

  • How to write data into xml through web service

    Hi,
      I have a requirement to write the data into xml through a web service .send me related links and sample code if any.

    hi kiran,
      write the data into xml : We need suitable set of java Beans for handling WebService Data.
       However, there are cases when you may prefer an alternate mapping, or when there just isn't a well-defined mapping for your particular schema construct (xsd:choice is a common example). For these cases, IBM® WebSphere® has introduced a new feature called Custom Data Binding that allows you to integrate alternate data binding technologies like JAX-B, EMF/SDO and XML beans, as well to define your own XML schema to Java mappings. This article provides an overview of the technology and how you can get started integrating it into your application.
    GO THru THis Links :
    http://www-128.ibm.com/developerworks/websphere/library/
    techarticles/0601_gallardo/0601_gallardo.html.
    Hope It Helps.
    Thanks
    Varun CN

  • How to convert idoc into xml/edifact

    hi everyone just now i have started to work on edi, i want to kno how to convert idoc into xml/edifact. plz  reply asap

    Firstly, I will reply when and if I choose to. I do not require the asap nonsense at the end of your sentence.
    EDIFACT - You will need a subsystem.
    XML - I am not 100%. It may also depend on what version of SAP you are on. As I do not know if later versions of SAP can convert IDoc to XML.

  • How to write to an XML file from JDE batch application?

    Hello everyone,
    I need to write data from a batch application to an XML file. I don't know how to use the XML business functions.
    I tried to use XML Publisher but the format is not the same as the client XML. The XML file has some customized format.
    I need to do it manually with business functions and ER. Please help me out.
    Some business functions I saw are Create XML document, XML Add element and XML Add attribute but the parameters are complex to
    use.
    Thank you very much.
    Edited by: Lovvy on Sep 8, 2010 2:58 AM

    The XML DB forum is better suited to your question.
    It also has a FAQ which details how to read and shred XML into tables as well as other common XML based questions...
    XML DB FAQ

  • How to write and read Xml file from database if possible?

    Hi all,
    I need to read the .Xml file when receives from Source systems and write the data into the table as well as write in the.xml file thru reading the data from table as per the client needs. I am stranger to this area. Since, please provide some examples how to approach the same.
    Thanks in advance !!
    Regards.
    Vissu.....

    The XML DB forum is better suited to your question.
    It also has a FAQ which details how to read and shred XML into tables as well as other common XML based questions...
    XML DB FAQ

  • How to write messages into system log(sm21) using c_write_syslog_entry

    Hi,
    May i know how to write my application messages into system log(sm21)
    using "c_write_syslog_entry". Any explanation regarding the Type. ID, Data
    will be useful with examples. Incase of any other FM's or C functions does
    the same Please let me know.
    Thanks
    Prasath

    Hello Prasanth
    I agree with Kareem that you should prefer the application log. If interface IF_RECA_MESSAGE_LIST is available on your SAP system this is the first choice for collecting messages AND storing them as application log.
    For an example you may have a look at my Wiki posting [Message Handling - Finding the Needle in the Haystack|https://wiki.sdn.sap.com/wiki/display/profile/2007/07/09/MessageHandling-FindingtheNeedleintheHaystack]
    Not shown in this example is the storage of the application log. However, if you look at method CF_RECA_MESSAGE_LIST=>CREATE you see that you can add the application log references here.
    Regards
      Uwe

  • How to write data to xml file?

    Hi,
    I have done a project which read data from a web then write in log file.
    Now i want to write data in xml file.
    how to write?
    i read some java and xml tutorial, quite quite difficult.
    Who can give a simple example with some comments?
    If you also give some tips on learning java web services, i will be very appreciated.
    Thanks
    Yang Bin

    Choose Xerces2.4 to serialize the DOM object is an option.
    javac XercesTest.java -classpath xmlParserAPIs.jar;xercesImpl.jar;.
    java -classpath xmlParserAPIs.jar;xercesImpl.jar;. XercesTest test.xml
    below is the source file: XercesTest.java
    //JAXP
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    //APACHE SERIALIZE FUNCTION
    import org.apache.xml.serialize.*;
    class XercesTest
    public static void main(String[] args) throws Exception
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse( new File( args[0] ) );
    File f = new File( "copy_of_"+ args[0] );
    OutputFormat format = new OutputFormat("xml","UTF-8",true ) ;
    FileOutputStream fout = new FileOutputStream( f );
    XMLSerializer ser = new XMLSerializer(fout, format );
    ser.serialize( doc );
    hope it's helpful
    land

  • How to convert HTML into XML

    I know I can parse XML into some HTML, but is there any tools or methods existed to parse HTML into XML?
    I have a not well-formed HTML with a lot data fields, including a lot not closed tags. This HTML is generated by some XML(as I can see), but I can't find a way to reform it into a XML, and eventually stored the data into another database.
    Anyone can help me? I appreciate!
    KIB

    As SAm has told you, you can use jTidy, for the purpose, a sample code , which can convert an html file to xml file is given at following url:
    see the documentation as well.
    http://sourceforge.net/docman/display_doc.php?docid=1298&group_id=13153
    gaurav_k1

  • How to write POJO for XML file.. i do not want to use JAXB or any other tec

    How to generate POJOs for the specific xml files.
    Each XML file will have elements name with Type. Which in turn related to some other xml file
    For example
    student.xml
    <student name"mystudent">
    <studentname type="firstname"/>
    <studentname type="firstname"/>
    <studentname type="firstname"/>
    </student>
    firstname.xml
    <studentname name="firstname">
    <stufirstname type="myfirstname"/>
    </studentname>
    myfirstname.xml
    <myfirstname name="myfirstname">
    <myname1>xxx</myname1>
    </myfirstname>
    like this there will be so many xml files interlinked.
    I would like to write POJOs for these xml files
    please let me know what is the best way to write (design the hirarchy of these xml files
    Thanks in advance
    srinivas

    Not at this time. You may submit your polite feedback to Apple using this webpage: http://www.apple.com/feedback/itunesapp.html

  • How to write data into a file

    Hi
    I want to write data from a string into a file. I am created a directory and a .doc file . But when i write this data from a string into .doc file , its give an error : File not found exception
    But, when i check in my directory, a file is created with blank.
    My code is:
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    class createFile {
         public static void main(String[] args) {
    try {
         String mss = "This is for dedo";
         FileInputStream fis;
         FileOutputStream fos;
    File file = new File("C:\\JD\\m4.rtf");
    // Create file if it does not exist
    boolean success = file.createNewFile();
         success = true;
    if (success) {
                   System.out.println("suc");     
                   fis = new FileInputStream(mss);
                   System.out.println(fis);
              fos = new FileOutputStream(file);
              int c;
                   while ((c = fis.read()) != -1) {
         fos.write(c);
                   System.out.println("mss");
              fis.close();
              fos.close();
         System.out.println("created");
    // File did not exist and was created
    } else {
    // File already exists
    } catch (IOException e) {
         System.out.println(e);
    regards
    madhu

    InputStream inputStream = new ByteArrayInputStream(mss.getBytes());Use this to push into the file>
    Ummm.... no. InputStreams are for reading, not for writing.
    Anyway, OP, you're making a mistake. You're trying to open a stream to a file called "This is for dedo". Use FileOutputStream(File file) constructor or FileOutputStream(String pathToFile). You can then wrap that stream with a PrintWriter or whatever you need.

  • How to fetch data into xml file trom sql table.

    Hi,
    We r now working in oracle 9iAS portal.
    We have installed xdk along with 9iAS.
    I would like to know how to and where to run an xsql file,preferably with an example to fetch data from a database table to a xml file.

    Please download the latest version of XDK for Java at:
    http://otn.oracle.com/tech/xml/xdk_java
    In the downloaded package, there are demos for XSQL Servlet. The demo "emp" and "empdept" are good start.

  • How to write file into multiple directories by using file adapter?

    i need to write my file into multiple directories,i able to do in single directory.But i need to write to muliple directories.Please help me out.Thanks in advance.

    If you are passing the values at runtime then you can loop it and and invoke the file adapter in loop by dynamically passing the value in invoke properties for "File Directory and File name" etc.

  • How to insert fragment into xml column generated from query

    I'm trying to generate xml from some relational data and then insert a sub node into an xml column. Here's some sample code that obviously doesn't work.  I'm trying to figure out the syntax where the ???? exist.
    /* create test tables*/
    DECLARE @person TABLE
    id int NOT NULL PRIMARY KEY CLUSTERED,
    info xml NULL
    DECLARE @roles TABLE
    id int NOT NULL,
    role_name varchar(20) NOT NULL,
    PRIMARY KEY
    id,
    role_name
    /* insert test values */
    INSERT INTO @person (id, info)
    VALUES (1, '<person><name><first_name>Joe</first_name><last_name>Smith</last_name></name></person>'),
    (2, '<person><name><first_name>Tim</first_name><last_name>Jones</last_name></name></person>');
    INSERT INTO @roles (id, role_name)
    VALUES
    (1,'Admin'),
    (1,'User'),
    (2,'Editor'),
    (2,'User');
    /* make sure that xml comes back correctly*/
    SELECT
    role_name AS name
    FROM @roles AS role
    WHERE id = 1 -- works for each id
    FOR XML AUTO, ROOT ('roles');
    UPDATE p
    SET info.modify('insert ???? as last into (/person)[1]')
    FROM @person p
    INNER JOIN @roles r
    ON p.id = r.id
    /* desired output in the info column for id = 1*/
    <person>
    <name>
    <first_name>Joe</first_name>
    <last_name>Smith</last_name>
    </name>
    <roles>
    <role name="Admin" />
    <role name="User" />
    </roles>
    </person>
    Any ideas?

    this?
    DECLARE @person TABLE
    id int NOT NULL PRIMARY KEY CLUSTERED,
    info xml NULL
    DECLARE @roles TABLE
    id int NOT NULL,
    role_name varchar(20) NOT NULL,
    PRIMARY KEY
    id,
    role_name
    /* insert test values */
    INSERT INTO @person (id, info)
    VALUES (1, '<person><name><first_name>Joe</first_name><last_name>Smith</last_name></name></person>'),
    (2, '<person><name><first_name>Tim</first_name><last_name>Jones</last_name></name></person>');
    INSERT INTO @roles (id, role_name)
    VALUES
    (1,'Admin'),
    (1,'User'),
    (2,'Editor'),
    (2,'User');
    /* make sure that xml comes back correctly*/
    SELECT
    role_name AS name
    FROM @roles AS role
    WHERE id = 1 -- works for each id
    FOR XML AUTO, ROOT ('roles');
    UPDATE p
    SET info.modify('insert sql:column("x") as last into (/person)[1]')
    FROM @person p
    CROSS APPLY(SELECT role_name FROM @roles WHERE id = p.id FOR XML PATH(''),ROOT('roles'),TYPE)r(x)
    select * from @person
    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

  • HOW TO  WRITE DATA INTO A CLOB VARIABLE IN PL SQL-URGENT!!!!!!!

    Hi,
    In a PLSQL procedure, i need to store all error messages into a CLOB variable and finally RETURN the Clob.
    While using DBMS_LOB.wirteappend, i am getting Error like
    "INVALID LOB LOCATOR SPECIFIED".
    Here is the code sample i used,
    CREATE OR REPLACE procedure ErrorAppend
    is
    clobObj CLOB;
    amt binary_integer:=32767;
    errormsg varchar2(2000);
    BEGIN
    for j in 1..3
    loop
    BEGIN
    insert into errortest values(j);
    EXCEPTION
    WHEN others THEN
    errormsg:='ERROR OCCURED '||SQLERRM;
    dbms_lob.writeappend(clobObj,amt,errormsg);
    END;
    commit;
    end loop;
    dbms_output.put_line(clobObj);
    END ErrorAppend;
    Here i am not allowed to get empty_clob/clob from the table.
    Any help will be apprciated.
    rgds,
    senthil.

    InputStream inputStream = new ByteArrayInputStream(mss.getBytes());Use this to push into the file>
    Ummm.... no. InputStreams are for reading, not for writing.
    Anyway, OP, you're making a mistake. You're trying to open a stream to a file called "This is for dedo". Use FileOutputStream(File file) constructor or FileOutputStream(String pathToFile). You can then wrap that stream with a PrintWriter or whatever you need.

  • How to attach XSL into XML generated by XMLEncoder?

    Hi everyone,
    I used XMLEncoder to generate an XML file. But XMLEncoder does not provide anyway to attach XSL style sheet before generating the XML. The only way I can attach XSL style sheet is to manually edit the XML file, which I do not want to do. Is there anyway to insert the XSL sytle sheet tag using Java code? Any suggestions? thanks

    I am not quite sure that this would work, but in theory (I have never tested it, and I am not a java-guru) it just might work. I havent worked a lot with piped streams either, so there might be a flaw there that I dont know about.
    import java.io.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    // Making the pipes
    PipedInputStream inpipe = new PipedInputStream();
    PipedOutputStream outpipe = new PipedOutputStream( inpipe );
    // Redirecting XML encoding to pipe
    new XMLEncoder( outpipe );
    // Making a transformer with xsl schema
    TransformerFactory tFactory = TransformerFactory.newInstance();
    StreamSource xslsource = new StreamSource( "xslsource.xsl")
    Transformer transformer = tFactory.newTransformer( xslsource );
    // Transforming from pipe to file
    StreamSource xmlsource = new StreamSource( inpipe );
    File xmlfile = new File( "xmlfile.xml" )
    StreamResult xmlresult = new StreamResult( xmlfile );
    transformer.transform( xmlsource, xmlresult );
    ...Think about it or try it out...
    Good luck!
    /Richard

Maybe you are looking for

  • New version of Numbers - two important questions

    I'm running the new version of Numbers and have some questions. First let me say that I switched from PC to Mac earlier this year.  I decided I wanted to try Numbers instead of Excel.  Although I do have Office for Mac installed as well.  I setup a b

  • Multiple Service Entry Sheet For PO Line Items and One GR Document

    Dear All, We have just migrated from ECC 5.0 System to ECC 6.0 System. We are facing a problem while processing service entry sheets and the GR against them. The scenario is: 1. We create a maintenance plan 2. Upon saving the Maintenance Plan, a Purc

  • PLEASE Quicktime component for AVI files?

    Trying to bring .AVI video files shot on Casio z750 over to Streamclip or at least START with QuickTime and THEN Streamclip so I can edit/burn family stuff in imovie/idvd.

  • Disable background window

    In the program I'm currently making, I use popup windows for some functions, and need to be able to disable the background window until the popup window has been closed. The JDialogOption has this functionality, is there any way to implement it in ot

  • Is there any way to change the label of my VO attributes

    hi , Is there any way to change the label of my VO attributes so that it will have more logical presentation Thanks Musahib