943,923 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 2082
  • JSP RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 18th, 2008
0

help me

Expand 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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rakesh.mk is offline Offline
7 posts
since Sep 2008
Sep 18th, 2008
0

Re: help me

Click to Expand / Collapse  Quote originally posted by rakesh.mk ...
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
Reputation Points: 935
Solved Threads: 356
Nearly a Posting Maven
stultuske is offline Offline
2,497 posts
since Jan 2007
Sep 19th, 2008
0

Re: help me

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.
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Phaelax is offline Offline
856 posts
since Mar 2004
Sep 20th, 2008
0

Re: help me

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rakesh.mk is offline Offline
7 posts
since Sep 2008
Sep 20th, 2008
0

Re: help me

Click to Expand / Collapse  Quote originally posted by Phaelax ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rakesh.mk is offline Offline
7 posts
since Sep 2008
Sep 20th, 2008
0

Re: help me

Click to Expand / Collapse  Quote originally posted by rakesh.mk ...
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,
Reputation Points: 51
Solved Threads: 24
Junior Poster
puneetkay is offline Offline
122 posts
since Nov 2007
Sep 26th, 2008
0

Re: help me

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rakesh.mk is offline Offline
7 posts
since Sep 2008
Sep 26th, 2008
0

Re: help me

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

JSP Syntax (Toggle Plain Text)
  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.

JSP Syntax (Toggle Plain Text)
  1. String username = comboBox.getSelectedItem().toString() ;
  2. DBManager dbM = new DBManager();
  3. try {
  4. dbM.method(username);
  5. } catch (Exception e) {
  6.  
  7. }
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
javaAddict is offline Offline
3,259 posts
since Dec 2007
Sep 27th, 2008
0

Re: help me

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rakesh.mk is offline Offline
7 posts
since Sep 2008
Sep 27th, 2008
-1

Re: help me

Is this part of an application or it should be used as part of web service?
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: Form data
Next Thread in JSP Forum Timeline: servlet +tomcat 5.0.28+access database+problems





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC