Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-27-2007, 01:46 PM
Member
 
Join Date: Jun 2007
Posts: 2
fareez is on a distinguished road
list problem
let say i have a lists of name
michael
john
sarah


then i put it into array
User userList[] =new User[];

then i create loop to print that list
for (int i=0; i<userList.length; i++{
listbox1.setItems(userList[i]);

anybody know how to modified this code if want to test every name if it have a condition like this:

michael is resident for apartement A
john n sarah are resident for apartment B

so i think i want to use if..else but i don't know how to code that..plz anybody help me...
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-27-2007, 07:38 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
hi fareez,

Please put your code inside [code] tags next time. That will be easier to read and correctly printed on the page.

Regarding your question:

You can keep two other integer arrays, one for apartment A and one for apartment B.

And assign index of each of your users to this arrays. So if "Michael is resident for apartment A" and index of Michael in userList is 1, then write the following in your initialization code:

Code:
apartmentA[0] = 1;
Then for this query: "is michael resident for apartement A", you will search apartementA array for the index of michael which was 1. If you find that, return true else false.

Let me know if something is unclear.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-28-2007, 06:19 AM
Member
 
Join Date: Jun 2007
Posts: 2
fareez is on a distinguished road
i already write a code like this.Is my coding right?:

Code:
PropertyInfo pInfo = PropertyInfoDAO.loadPropertyInfoByORMID(this.getSessionBean1().getPropertyID()); User[] userList = UserDAO.listUserByQuery(null,null); Option[] optUser = new Option [userList.length]; int y = 0; for (int i=0; i<userList.length; i++){ if (userList[i].inCharge.contains(pInfo)){
//condition
else {
//condition

i query apartment id using below code:
Code:
PropertyInfo pInfo = PropertyInfoDAO.loadPropertyInfoByORMID(this.getSessionBean1().getPropertyID());
Actually i have 2 pages which is the previous page have a list of apartment.I create link for apartment name,then when i click that link,such as i click link for apartment A,it will go to the next page which contains a residents list for apartment A.

I put resident list in listbox component.I use 2 listboxes. I name it listbbox1 and listbox2.If michael is resident for apartment A,his name will appear in listbox1 and john and sarah will appear in listbox2 because they are not resident for aparment A.

The case is same for apartment B. Sarah and Michael will appear in listbox1 but michael will appear in listbox 2 becase michael is not resident for apartmentB
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-28-2007, 12:26 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
Hmm, sorry i am not experienced with Java EE. You might try asking this on one of the Java EE subforums. You can find more people to answer.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Members List Eranga Suggestions & Feedback 11 01-17-2008 12:41 PM
Array List Problem khamuruddeen New To Java 1 12-22-2007 10:10 AM
List and ArrayList ravian New To Java 2 12-10-2007 01:40 PM
list Zensai New To Java 3 11-20-2007 09:22 AM
How to get the max value from a list osval New To Java 1 07-30-2007 07:43 PM


All times are GMT +3. The time now is 12:38 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org