User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 391,558 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,739 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1074 | Replies: 5 | Solved
Reply
Join Date: Mar 2007
Posts: 15
Reputation: pmhayden is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
pmhayden pmhayden is offline Offline
Newbie Poster

Question accessing info created in one class, in another class

  #1  
Aug 14th, 2007
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2006
Location: City of God
Posts: 145
Reputation: orko is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 8
orko orko is offline Offline
Junior Poster

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

  #2  
Aug 14th, 2007
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 5:29 pm.
A Perfect World
Reply With Quote  
Join Date: Mar 2007
Posts: 15
Reputation: pmhayden is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
pmhayden pmhayden is offline Offline
Newbie Poster

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

  #3  
Aug 14th, 2007
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
Reply With Quote  
Join Date: Apr 2006
Location: City of God
Posts: 145
Reputation: orko is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 8
orko orko is offline Offline
Junior Poster

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

  #4  
Aug 14th, 2007
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.
A Perfect World
Reply With Quote  
Join Date: Mar 2007
Posts: 15
Reputation: pmhayden is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
pmhayden pmhayden is offline Offline
Newbie Poster

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

  #5  
Aug 15th, 2007
Tanx for that help,
that answers my question
Reply With Quote  
Join Date: Apr 2006
Location: City of God
Posts: 145
Reputation: orko is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 8
orko orko is offline Offline
Junior Poster

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

  #6  
Aug 15th, 2007
u r welcome... ... it really feels good in helping other...
A Perfect World
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 9:54 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC