| | |
accessing info created in one class, in another class
Thread Solved |
•
•
Join Date: Mar 2007
Posts: 15
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Apr 2006
Posts: 164
Reputation:
Solved Threads: 10
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.
A Perfect World
•
•
Join Date: Mar 2007
Posts: 15
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Apr 2006
Posts: 164
Reputation:
Solved Threads: 10
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.
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
![]() |
Similar Threads
- Class and Sub Class (Java)
- Java Class Class problem (Java)
- Class in a class... (Java)
- Calling button-click events from different classes (Python)
- changing properties of a widget created in one class whilst in another class (Python)
- How to access a variable of a diff class (C++)
- Accessing functions from base class (C)
Other Threads in the Java Forum
- Previous Thread: Filter JTextField and Display in JTable
- Next Thread: getting error: misplaced constructs
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary block bluetooth character class client code component consumer csv database desktop developmenthelp eclipse error fractal ftp game gameprogramming givemetehcodez graphics gui html ide image integer j2me j2seprojects japplet java javaarraylist javac javaee javaprojects jni jpanel julia lego linked linux list loops mac map method methods mobile netbeans newbie number objects online oriented panel printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server set singleton sms sort sql string swing system test textfields threads time title tree tutorial-sample ubuntu update windows working





... it really feels good in helping other...
