help me

Reply

Join Date: Sep 2008
Posts: 7
Reputation: rakesh.mk is an unknown quantity at this point 
Solved Threads: 0
rakesh.mk rakesh.mk is offline Offline
Newbie Poster

help me

 
0
  #1
Sep 18th, 2008
Hi I am trying get user info from the database into the textbox when i select Usename Which is stored in the drop down. so could any help how to get all usernames into dropdown and when i select any usenames i should get all details into the text box.........please elp me
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: help me

 
0
  #2
Sep 18th, 2008
Originally Posted by rakesh.mk View Post
Hi I am trying get user info from the database into the textbox when i select Usename Which is stored in the drop down. so could any help how to get all usernames into dropdown and when i select any usenames i should get all details into the text box.........please elp me
what is your question? how to get the usernames and put them in the drop down box, or how to get the userinfo based on these users?

write a class to connect to the db, write the code that reads the date in the db and use it.

first of all, this forum is not intended to deliver instant j2ee sollutions, and even if it was, we don't know what you are doing, whether you are using a framework, ...

make a start and come back with questions about your code, not with the classical no-no "plz write mah codez" or something of that sort
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 765
Reputation: Phaelax is on a distinguished road 
Solved Threads: 38
Phaelax Phaelax is offline Offline
Master Poster

Re: help me

 
0
  #3
Sep 19th, 2008
This all depends entirely on where your usernames are stored. In a database? A file? Hard-coded?(better not be)

Open the Java API docs and review the contructors for JComboBox (assuming you plan to use the Swing framework) and that'll give you some ideas on how to add usernames to the drop-down list.

http://java.sun.com/docs/books/tutor.../combobox.html

Add an ActionListener to the combo box to listen for when a username is selected from the list. Then simply connect to your database and pull the information you need. JTextField.setText() will set the text of the text box.
Last edited by Phaelax; Sep 19th, 2008 at 6:06 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 7
Reputation: rakesh.mk is an unknown quantity at this point 
Solved Threads: 0
rakesh.mk rakesh.mk is offline Offline
Newbie Poster

Re: help me

 
0
  #4
Sep 20th, 2008
Ok thanks for your help, Actually i need to edit the user information which is stored in the mysql database, for that i need to fetch the data from database for perticular user. I have written java class in that I am storing all the usernames in an Array list. I need to display these ArrayList usernames in drop down box. I dont how to do that pls help me
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 7
Reputation: rakesh.mk is an unknown quantity at this point 
Solved Threads: 0
rakesh.mk rakesh.mk is offline Offline
Newbie Poster

Re: help me

 
0
  #5
Sep 20th, 2008
Originally Posted by Phaelax View Post
This all depends entirely on where your usernames are stored. In a database? A file? Hard-coded?(better not be)

Open the Java API docs and review the contructors for JComboBox (assuming you plan to use the Swing framework) and that'll give you some ideas on how to add usernames to the drop-down list.

http://java.sun.com/docs/books/tutor.../combobox.html

Add an ActionListener to the combo box to listen for when a username is selected from the list. Then simply connect to your database and pull the information you need. JTextField.setText() will set the text of the text box.
Ok thanks for your help, Actually i need to edit the user information which is stored in the mysql database, for that i need to fetch the data from database for perticular user. I have written java class in that I am storing all the usernames in an Array list. I need to display these ArrayList usernames in drop down box. I dont how to do that pls help me
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 121
Reputation: puneetkay is on a distinguished road 
Solved Threads: 23
puneetkay's Avatar
puneetkay puneetkay is offline Offline
Junior Poster

Re: help me

 
0
  #6
Sep 20th, 2008
Originally Posted by rakesh.mk View Post
Ok thanks for your help, Actually i need to edit the user information which is stored in the mysql database, for that i need to fetch the data from database for perticular user. I have written java class in that I am storing all the usernames in an Array list. I need to display these ArrayList usernames in drop down box. I dont how to do that pls help me
Hello,

There are two ways to add usernames from ArrayList to ComboBox (that i have in mind now).

One is using forloop, Get each username from ArrayList and add it to ComboBox.

and second one is, Get Array object from ArrayList using toArray() method.

JComboBox comboObj = new JComboBox(Object []usernames);

and use this constructor. This will automatically add all elements of Array into ComboBox.

Regards,
Puneet Kalra
www.PuneetK.com
Sun Certified Java Programmer


Admin of Pikk - Object Relational Mapping Framework
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 7
Reputation: rakesh.mk is an unknown quantity at this point 
Solved Threads: 0
rakesh.mk rakesh.mk is offline Offline
Newbie Poster

Re: help me

 
0
  #7
Sep 26th, 2008
I need to fetch the data from database by using usernames which is in drop down, for this i need to write a query such that for where condition in query i need give the username,....then that query will execute and it vl return some user data.Now the problem is whenthe user select username which is in drop down that username should be the condition in query i dont know how to use this username in my query.......some one told me to use session....is it ok shell i use session...please help me its very urgent
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,677
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 226
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: help me

 
0
  #8
Sep 26th, 2008
Next time be more clear about what is your problem. From what I understood you don't know how to get and use the username from the comboBox?

If yes assume that you have a String username variable. For getting the value from a comboBox that has String elements do this:

String username = comboBox.getSelectedItem().toString() ;

Then create in a seperate class a method that take as argument that username and calls your query

  1. class DBManager {
  2. public void/*or whatever you want to return*/ method(String username) throws SQLException {
  3. // code here
  4. }

And call it with argument what you get from the comboBox.

  1. String username = comboBox.getSelectedItem().toString() ;
  2. DBManager dbM = new DBManager();
  3. try {
  4. dbM.method(username);
  5. } catch (Exception e) {
  6.  
  7. }
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 7
Reputation: rakesh.mk is an unknown quantity at this point 
Solved Threads: 0
rakesh.mk rakesh.mk is offline Offline
Newbie Poster

Re: help me

 
0
  #9
Sep 27th, 2008
thats ok after getting the data from the database i need to display the values in text fields. I mean when i select the username in drop down all the information of that perticular user should be displayed in the text.......which is nothing but getting user info...so wat i have to do?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,205
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 486
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: help me

 
-1
  #10
Sep 27th, 2008
Is this part of an application or it should be used as part of web service?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JSP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC