This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Passing Value from 1 class 2 another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Passing Value from 1 class 2 another" Watch "Passing Value from 1 class 2 another" New topic
Author

Passing Value from 1 class 2 another

Anand Karia
Ranch Hand

Joined: Sep 25, 2004
Posts: 156

Dear All

I m a new user of java.

plz help me out 2 solve my problem.

1 class = dbconnection
2 class = util
3 class = company
4 class = login

i ve connected database with dbconnection in login form using
dbconnection conn = new dbconnection();

then userid is asked. When i enter my login it passes value to util class
util u = new util(); // this is initialized at top.
u.setValue(txtUserId.getText());

public String setValue(String str)
{ String myVal
myVal = str;
System.out.println(myVal);
return myVal;
}

when i m trying to print that value i is showing user id.

I ve a button on login form called "Company".
I ve inititlized util object at the top.

util abc = new util();

Problem:
========
i want to get the value that i ve assigned in my login form using setValue() method.

But when ever i m getting value from util class it shows null value;
Plz tell where i m wrong?

ANAND


Love is GOD and GOD is Love.
Anand Karia
IT Concretor.......
M/s. Anand Karia Concreting IT
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
check on
Michal Bienek
Greenhorn

Joined: Jun 17, 2002
Posts: 29
If you are attempting to perform a util.getValue() to fetch the value after it is set, you will not get a value since you initialized the myVal String within your util.setValue(String str) method. In order to retrieve this value, you will have to create a class member that you would populate in the setValue(String str) method and retrieve via the getValue() method
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
This is a duplicate of another post.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing Value from 1 class 2 another