Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7689041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:04:21+00:00 2026-05-31T20:04:21+00:00

I have an array list named newSymptomList which contains a list of Symptom id’s

  • 0

I have an array list named “newSymptomList” which contains a list of Symptom id’s (e.g. [1,3,4]) generated by a pick list target. I want to go through each symptom and get the relevant symptom name from the database although I’m stuck on the while loop.

PickList:

<rich:pickList id="plID" listWidth="10em" 
                        value="#{sym.newSymptomList}" 
                        sourceCaption="Symptoms" 
                        targetCaption="Selected Symptoms">
                    <!--List of all Symptoms-->
                    <f:selectItems value="#{sym.allSym}" var="c"
                                   itemLabel="#{c.symptomName}" itemValue="#{c.symptomId}"/>
</rich:pickList>

Relevant code in SymptomBean:

private List<Symptom> newSymptomList = new ArrayList<Symptom>();

public List getNewSymptomList()
{
  return newSymptomList;
}

public void setNewSymptomList(List<Symptom> newSymptomList )
{
  this.newSymptomList = newSymptomList; 
}

//Here is the code which returns a list of matching symptom names:

public List getSymNames() {
    List selectedSymptoms= new ArrayList(); 
    int i = 0;
    try
    {
        Class.forName("com.mysql.jdbc.Driver");
        con = ...
        ps = con.createStatement();
        rs = ps.executeQuery("select * from symptoms");
        while (rs.getString(1)== newSymptomList) {
            //getString(1) is symptomID and getString(2) is symptomName
            selectedSymptoms.add(i,new Symptom(rs.getString(1), rs.getString(2)));
            i++;
        }
    }//end of try

    catch (Exception e)
    {
        System.out.println("Error Data : " + e.getMessage());
    }

    return selectedSymptoms;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:04:22+00:00Added an answer on May 31, 2026 at 8:04 pm

    You’re going in the wrong direction as to achieving the requirement. You have the symptom names already there in the allSym list as referenced by <f:selectItems>. Your mistake is that you’re setting the selected symptoms as List<Symptom> while it should actually be a List<String> or whatever type the #{c.symptomId} actually is (it seems to be String as you’re attempting to get it by ResultSet#getString(), which is not a sane type, but that aside), otherwise you would get a ClassCastException when iterating over it.

    Fix it accordingly:

    private List<String> newSymptomList; // +getter+setter.
    

    Finally, you could just go through the allSym list which you already have there in the same bean to get the Symptom objects.

    List<Symptom> selectedSymptoms = new ArrayList<Symptom>();
    
    for (Symptom symptom : allSym) {
        if (newSymptomList.contains(symptom.getSymptomId())) {
            selectedSymptoms.add(symptom);
        }
    }
    
    // ...
    

    Another way is to keep the newSymptomList a real List<Symptom> and fix the itemValue of your <f:selectItems> to be #{c} instead of #{c.symptomId}. You only need to implement a javax.faces.converter.Converter so that JSF will be able to automatically convert between Symptom and its unique String representation. For an example, see also our <h:selectOneMenu> tag wiki page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how to compare value in an array? I have array named list which contains
I have a collection (or list or array list) in which I want to
I have an array containing a list of files. I want to sort it
I have an array named Floors in class A, it contains values something like
I have an array list of Fleets (Each fleet will hold its own list
Let's say I have a list of selects that are all named batters[] which
I have a TV named Kategorie and I want a list of all resources
I have array from serial read, named sensor_buffer . It contains 21 bytes. gyro_out_X=((sensor_buffer[1]<<8)+sensor_buffer[2]);
I have a data file named somedata.dat, it contains a list of number pairs.
I have a (2, 500) numpy array named county_data . I want to iterate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.