The Artima Developer Community
Sponsored Link

Java Answers Forum
Java If statement (blacklist)

8 replies on 1 page. Most recent reply: Mar 16, 2006 4:40 AM by Eelco de Vries

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 8 replies on 1 page
Eelco de Vries

Posts: 6
Nickname: eelco1985
Registered: Mar, 2006

Java If statement (blacklist) Posted: Mar 16, 2006 1:39 AM
Reply to this message Reply
Advertisement
Hello People,

I got an Application in which is connected to a database with employee's

now it's pssible to put people on a so called blacklist.

In the database a Boolean will be set to True and than the people are on the blacklist now my point is if they are on the blacklist they shouldn't be appearing in the Java program now I need some kind of If statement which says that if the boolean of a person is set to true this person should not be shown and if it's set to False it should be shown.

this also works the other way around casue they can select a tab called "blacklist" and in this tab all the persons that are on the blacklist should be shown. (But I guess this is just the other way around)
So can someone please help me with this if statement?
(sorry for my poor English)


Dave Hinton

Posts: 42
Nickname: catbells
Registered: Oct, 2003

Re: Java If statement (blacklist) Posted: Mar 16, 2006 2:33 AM
Reply to this message Reply
To be honest, it sounds like you should be filtering out the blacklisted entries in the SQL query, rather than refiltering the results in java.

Eelco de Vries

Posts: 6
Nickname: eelco1985
Registered: Mar, 2006

Re: Java If statement (blacklist) Posted: Mar 16, 2006 2:58 AM
Reply to this message Reply
is this enough than??

SELECT * FROM Werknemer WHERE blacklist='False'


or do you mean it in another way?

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Java If statement (blacklist) Posted: Mar 16, 2006 2:59 AM
Reply to this message Reply
Without any information how you store the list and how you display it, it's not that easy to show you how to modify it.

As mentioned by Eelco, the best way would be to include the filter in the SQL statement.

If you don't want to do this, there are 2 possibilities.
Either you decide if you want to add the person while you read each line of the ResultSet, or you first read the whole resultset, create a list with every person including informations about the flag, loop through this list and put every person with a certaing flag value to another list.

Eelco de Vries

Posts: 6
Nickname: eelco1985
Registered: Mar, 2006

Re: Java If statement (blacklist) Posted: Mar 16, 2006 3:03 AM
Reply to this message Reply
Would the statement I just posted be enough???

Eelco de Vries

Posts: 6
Nickname: eelco1985
Registered: Mar, 2006

Re: Java If statement (blacklist) Posted: Mar 16, 2006 3:39 AM
Reply to this message Reply
what could be wrong with this?

SELECT Bedrijfsnaam, Plaats, Contactpersoon, Waardering, Blacklist FROM OpdrachtgeverNAW WHERE Blacklist = 'false'


we tried instead of false Nee (because we are dutch.... but that it doesn't work while if we try waardering = ****
than it does select everyone with waardering = ****

how could that be?

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Java If statement (blacklist) Posted: Mar 16, 2006 3:48 AM
Reply to this message Reply
Is the column Blacklist a String (CHAR or VARCHAR)?
Then it should work.


If it is Boolean, use "... where Blacklist = false"
Hint for Boolean types: I am German, but I would never use "Wahr", even if the SQL language would support it. Always use the standard, which is "TRUE".

Use "select distinct Blacklist from OpdrachtgeverNAW" and print out the result, then you know what you have to put in (Nee, False, Falsch, or whatever).

Eelco de Vries

Posts: 6
Nickname: eelco1985
Registered: Mar, 2006

Re: Java If statement (blacklist) Posted: Mar 16, 2006 4:34 AM
Reply to this message Reply
Oke thank you it works we created an blacklist and we created a list with all employee's

now what we need next is that you can right click on an employee in the normal list and than you can choose between things like:

"Edit"
"put on blacklist"

and that when you click on "put on blacklist" the box behind the user (in the database) will be checked and the user will be removed from the normal list and put on the blacklist.

and when he enters "edit" he can edit in a new tab all the information from that user like age etc...

I hope this is also possible :$

Eelco de Vries

Posts: 6
Nickname: eelco1985
Registered: Mar, 2006

Re: Java If statement (blacklist) Posted: Mar 16, 2006 4:40 AM
Reply to this message Reply
So can someone give me some code to make this right mouse click menu and can someone give me some code or explain how to put them on the blacklist and get in the edit menu as shown above....

Flat View: This topic has 8 replies on 1 page
Topic: rmiregistry healing needed! Previous Topic   Next Topic Topic: double method calls

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use