• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class For Appending Data  RSS feed

 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I am doing a project. It has many forms for Data Input.

I would like to create a class which will be called from the Form classes * (*extends JFrame) for reading, Creating and returning the data when I press save button. The class will read values from the JFrame input components using while loop and create and return a string from these values resembling XML Document structure("<nameJTextField>Good Boy</nameJTextField>") . The data will then be passed to another class which will extract these data from the XML Schema and send to JDBC for data insert/update.

I dont like to make array or XML string in the same JFrame classes as it will be rather confusing and difficult to maintain. So, How can I make a single Class to create and return the string containing input Values with their Ids?

Thanks & Regards

Prithiraj
[ January 09, 2008: Message edited by: Prithiraj Sen Gupta ]
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I am doing a project. It has many forms for Data Input.

I would like to create a class which will be called from the Form classes * (*extends JFrame) for reading, Creating and returning the data when I press save button. The class will read values from the JFrame input components using while loop and create and return a string from these values resembling XML Document structure("<nameJTextField>Good Boy</nameJTextField>") . The data will then be passed to another class which will extract these data from the XML Schema and send to JDBC for data insert/update.

I dont like to make array or XML string in the same JFrame classes as it will be rather confusing and difficult to maintain. So, How can I make a single Class to create and return the string containing input Values with their Ids?

Thanks & Regards

Prithiraj
 
Campbell Ritchie
Marshal
Posts: 55770
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe:

Create a class which encapsulates the various parts of the input as its fields, then put those objects into a List.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Prithiraj Sen Gupta:
Hello.

I am doing a project. It has many forms for Data Input.

I would like to create a class which will be called from the Form classes * (*extends JFrame) for reading, Creating and returning the data when I press save button.
Prithiraj


Since you are extending JFrame, you can use the getComponentCount() and getComponentAt(int index) to iterate through the UI components. After checking the class of the component, you can call the appropriate getters on these components to extract the values and process them further.
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I planned is that : -

I created an instance of the class inputmovers(explained in next paragraph) inside the actionPerformed method of my class userdataentry(extends JFrame). And passed the instance(of userdataentry) to the xmlCreator() method of inputmover class.
I am using netbeans.
The detail can be seen in the codes:-


I made a class inputmover. Then I create one method named xmlCreator which returns string and take Object obj as argument.

The following are the codes :


The above class inputmover is not compiled because the sentence obj.getComponentCount(); is showing error(cannot find symbol). What could be done to make an xml string as I have queried earlier in this Post.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!