-
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 =?"
-
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 =?"
-
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%'
-
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 + "'";
-
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks