Click here to Skip to main content
15,900,818 members
Home / Discussions / Java
   

Java

 
Questiondisable minimize button in JFrame Pin
Member 78380275-Jul-12 5:19
Member 78380275-Jul-12 5:19 
AnswerRe: disable minimize button in JFrame Pin
TorstenH.5-Jul-12 19:10
TorstenH.5-Jul-12 19:10 
Questionjava database Pin
Member 82109845-Jul-12 5:17
Member 82109845-Jul-12 5:17 
AnswerRe: java database Pin
jschell5-Jul-12 6:20
jschell5-Jul-12 6:20 
QuestionProvider Pin
JimAce5-Jul-12 0:53
JimAce5-Jul-12 0:53 
AnswerRe: Provider Pin
TorstenH.5-Jul-12 1:19
TorstenH.5-Jul-12 1:19 
GeneralRe: Provider Pin
JimAce5-Jul-12 4:12
JimAce5-Jul-12 4:12 
QuestionElegant validation? Pin
Neo101014-Jul-12 4:33
Neo101014-Jul-12 4:33 
Given the following code:

XML
private String name;
private List<String> years;
private List<String> studyChoices;

    private void doCheck() {
        if (!name.isEmpty() || name == null) {

        }
        for (String year : years) {
            if (!year.isEmpty() || year == null) {

            }
        }
        for (String studyChoice : studyChoices) {
            if (!studyChoice.isEmpty() || studyChoice == null){

            }
        }
    }


How do I condense this code into a more elegant and OO solution? Maybe put it all in one list and check for each item in that list?

I would like something like:

'If any of these parameters were not passed in or if they are empty, output an error message, else give the desired output'.

Basically I have to write a Servlet that gets form parameters from the request and checks if all parameters were provided. If they were, it is then supposed to write an output page.

Any ideas?

Thanks
AnswerRe: Elegant validation? Pin
Richard MacCutchan4-Jul-12 5:06
mveRichard MacCutchan4-Jul-12 5:06 
AnswerRe: Elegant validation? Pin
TorstenH.4-Jul-12 22:46
TorstenH.4-Jul-12 22:46 
Questionlocation-awareness simulation project Pin
simbarashe gumbo28-Jun-12 3:41
simbarashe gumbo28-Jun-12 3:41 
AnswerRe: location-awareness simulation project Pin
Peter_in_278028-Jun-12 3:48
professionalPeter_in_278028-Jun-12 3:48 
AnswerRe: location-awareness simulation project Pin
TorstenH.28-Jun-12 19:03
TorstenH.28-Jun-12 19:03 
AnswerRe: location-awareness simulation project Pin
CodingLover2-Jul-12 15:54
CodingLover2-Jul-12 15:54 
AnswerRe: location-awareness simulation project Pin
Paul Conrad2-Jul-12 17:50
professionalPaul Conrad2-Jul-12 17:50 
Questionto open an excel file and write Pin
prithaa27-Jun-12 21:50
prithaa27-Jun-12 21:50 
GeneralRe: to open an excel file and write Pin
Richard MacCutchan27-Jun-12 22:31
mveRichard MacCutchan27-Jun-12 22:31 
GeneralRe: to open an excel file and write Pin
prithaa27-Jun-12 23:05
prithaa27-Jun-12 23:05 
GeneralRe: to open an excel file and write Pin
Richard MacCutchan27-Jun-12 23:22
mveRichard MacCutchan27-Jun-12 23:22 
GeneralRe: to open an excel file and write Pin
prithaa27-Jun-12 23:33
prithaa27-Jun-12 23:33 
GeneralRe: to open an excel file and write Pin
Richard MacCutchan28-Jun-12 0:09
mveRichard MacCutchan28-Jun-12 0:09 
GeneralRe: to open an excel file and write Pin
prithaa28-Jun-12 20:21
prithaa28-Jun-12 20:21 
GeneralRe: to open an excel file and write Pin
Anil Kumar 2328-Jun-12 22:12
Anil Kumar 2328-Jun-12 22:12 
GeneralRe: to open an excel file and write Pin
Richard MacCutchan28-Jun-12 22:19
mveRichard MacCutchan28-Jun-12 22:19 
GeneralRe: to open an excel file and write Pin
prithaa29-Jun-12 0:04
prithaa29-Jun-12 0:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.