-
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...
-
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:
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.
-
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)){
[CENTER]//condition[/CENTER]
else {
[CENTER]//condition[/CENTER]
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
-
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.