DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Priscilla Guest

    How to track the value of the dropdown list


    Is there anyone able to help me out? I'm facing these difficulties:
    - I have to track what a user had selected from a drop down list, so that
    I can obtain the option value.
    - How do I retrieve matching data from the database, using the value I derived
    from the above. eg "Select * From QTNTable Where QTNYR =?"

  2. #2
    MarkN Guest

    Re: How to track the value of the dropdown list


    When the user selects something in the list, have your controller keep a reference
    to that corresponding object from the model. When you want to query your
    persistance to retrieve the object related to the object your controller
    has a reference to pass the required object/value.


    Mark


    "Priscilla" <java.@127.0.0.1> wrote:
    >
    >Is there anyone able to help me out? I'm facing these difficulties:
    >- I have to track what a user had selected from a drop down list, so that
    >I can obtain the option value.
    >- How do I retrieve matching data from the database, using the value I derived
    >from the above. eg "Select * From QTNTable Where QTNYR =?"



  3. #3
    Soft Solution System Limited Guest

    Re: How to track the value of the dropdown list

    > Is there anyone able to help me out? I'm facing these difficulties:
    > - I have to track what a user had selected from a drop down list, so that
    > I can obtain the option value.


    Object obj = list.getSelectedItem();

    you need to cast back your class

    > - How do I retrieve matching data from the database, using the value I

    derived
    > from the above. eg "Select * From QTNTable Where QTNYR =?"


    you can use the 'like' operator, e.g. where QTNYR like '%2000%'



  4. #4
    Chris Guest

    Re: How to track the value of the dropdown list


    String item = myList.getSelectedItem().toString();
    String sql = "Select * From QTNTable Where QTNYR = " + item;

    Remember to put single quotes around your data if necessary:

    sql = "Select * From QTNTable Where QTNYR = '" + item + "'";




  5. #5
    MarkN Guest

    Re: How to track the value of the dropdown list


    "Chris" <java.@127.0.0.1> wrote:
    >
    >String item = myList.getSelectedItem().toString();
    >String sql = "Select * From QTNTable Where QTNYR = " + item;
    >
    >Remember to put single quotes around your data if necessary:
    >
    >sql = "Select * From QTNTable Where QTNYR = '" + item + "'";
    >
    >
    >


    If you load your dd with strings then this will work. But with Swing/AWT
    one should use the models and display objects (Other than strings) which
    probably means you won't be doing this.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links