944,117 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 3739
  • Java RSS
Aug 14th, 2007
0

accessing info created in one class, in another class

Expand Post »
Hi
doing a project which consists of moving between individual frames and in general interrogating a database from these frames. My first frame is a Logon frame. In this Logon Frame/class i have also instantiated another class called Member where I've saved the username from the logon process.
Can I, or how can I use this (current) username information in the member class that I instantiated at logon, in a frame/class further down the line in the project.

Thanks a lot
paidi
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pmhayden is offline Offline
15 posts
since Mar 2007
Aug 14th, 2007
0

Re: accessing info created in one class, in another class

there is different ways to solve the problem. you can store the value in a static variable if you have only one user at a time (which is not the case i believe), or you can directly access the variables of object [hint: every user is an object. login informations, sessions can be instances. you just have to call them by accessing the objects]
Last edited by orko; Aug 14th, 2007 at 6:29 pm.
Reputation Points: 46
Solved Threads: 11
Junior Poster
orko is offline Offline
164 posts
since Apr 2006
Aug 14th, 2007
0

Re: accessing info created in one class, in another class

Hi thanks for taking the time to reply.

In logon frame/class I instantiated a Member class and saved the username, memID and now want to use the memID to help in a book reservation further on in a different frame/class.

I suppose what i'm unclear on is if I instantiate a Member class in the Reservation class, does this have access to what I've already saved to the member class I instantiated at Logon or not(as i suspect)?
Would my syntax in the reservation class be:
Member mem = new Member();
int id = mem.getMemID();

Tanx Paidi
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pmhayden is offline Offline
15 posts
since Mar 2007
Aug 15th, 2007
0

Re: accessing info created in one class, in another class

u have to use session, which will make sure the same user is accessing.

the code u have given shud return u a default value or null pointer exception... whn u r creating new member, it doesn't have any previous information... it is totally new.... if u want to work on same previous member in 2 differenct classes, u have to pass the member information.... good inheritance may help u in getting better solution.
Reputation Points: 46
Solved Threads: 11
Junior Poster
orko is offline Offline
164 posts
since Apr 2006
Aug 15th, 2007
0

Re: accessing info created in one class, in another class

Tanx for that help,
that answers my question
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pmhayden is offline Offline
15 posts
since Mar 2007
Aug 15th, 2007
0

Re: accessing info created in one class, in another class

u r welcome... ... it really feels good in helping other...
Reputation Points: 46
Solved Threads: 11
Junior Poster
orko is offline Offline
164 posts
since Apr 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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 Java Forum Timeline: Filter JTextField and Display in JTable
Next Thread in Java Forum Timeline: getting error: misplaced constructs





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


Follow us on Twitter


© 2011 DaniWeb® LLC