| View previous topic :: View next topic |
| Author |
Message |
kubota2550@gmail.com Posted via mailing list.
|
Posted: Tue Oct 28, 2008 6:51 pm Post subject: JavaDB ComboBox |
|
|
| How can I populate a combobox with javadb table data and then use the selected item to pupulate the master table? I have tried to bind to the table but the what shows up is the table name. |
|
| Back to top |
|
 |
Omar Vazquez Posted via mailing list.
|
Posted: Wed Oct 29, 2008 3:47 pm Post subject: JavaDB ComboBox |
|
|
what technology are you using?? i have some examples with servlets and jsp.
2008/10/28 address-removed ([email]address-removed[/email]) <address-removed ([email]address-removed[/email])>
| Quote: |
How can I populate a combobox with javadb table data and then use the selected item to pupulate the master table? I have tried to bind to the table but the what shows up is the table name. |
--
OJVM |
|
| Back to top |
|
 |
kubota2550@gmail.com Posted via mailing list.
|
Posted: Wed Oct 29, 2008 5:02 pm Post subject: JavaDB ComboBox |
|
|
Netbeans 6.5 on Windows using java.
On Wed, Oct 29, 2008 at 11:47 AM, Omar Vazquez <address-removed ([email]address-removed[/email])> wrote:
| Quote: | what technology are you using?? i have some examples with servlets and jsp.
2008/10/28 address-removed ([email]address-removed[/email]) <address-removed ([email]address-removed[/email])>
| Quote: |
How can I populate a combobox with javadb table data and then use the selected item to pupulate the master table? I have tried to bind to the table but the what shows up is the table name. |
--
OJVM
|
|
|
| Back to top |
|
 |
Omar Vazquez Posted via mailing list.
|
Posted: Wed Oct 29, 2008 6:02 pm Post subject: JavaDB ComboBox |
|
|
Are you developing a swing or awt or jsp? i mean desktop o web application?
2008/10/29 address-removed ([email]address-removed[/email]) <address-removed ([email]address-removed[/email])>
| Quote: | Netbeans 6.5 on Windows using java.
On Wed, Oct 29, 2008 at 11:47 AM, Omar Vazquez <address-removed ([email]address-removed[/email])> wrote:
| Quote: | what technology are you using?? i have some examples with servlets and jsp.
2008/10/28 address-removed ([email]address-removed[/email]) <address-removed ([email]address-removed[/email])>
| Quote: |
How can I populate a combobox with javadb table data and then use the selected item to pupulate the master table? I have tried to bind to the table but the what shows up is the table name. |
--
OJVM
|
|
--
OJVM |
|
| Back to top |
|
 |
lemba
Joined: 03 Oct 2008 Posts: 9
|
Posted: Wed Oct 29, 2008 6:11 pm Post subject: |
|
|
Hi,
- write method which returns String[] i.e. private String[] getValues()
in this method you make SELECT from your db.
populate ArrayList with your selected values.
convert ArrayList to regular array
- JComboBox cb = new JComboBox( getValues() ) |
|
| Back to top |
|
 |
kubota2550@gmail.com Posted via mailing list.
|
Posted: Wed Oct 29, 2008 8:52 pm Post subject: JavaDB ComboBox |
|
|
Swing desktop app.
On Wed, Oct 29, 2008 at 2:01 PM, Omar Vazquez <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Are you developing a swing or awt or jsp? i mean desktop o web application?
2008/10/29 address-removed ([email]address-removed[/email]) <address-removed ([email]address-removed[/email])>
| Quote: | Netbeans 6.5 on Windows using java.
On Wed, Oct 29, 2008 at 11:47 AM, Omar Vazquez <address-removed ([email]address-removed[/email])> wrote:
| Quote: | what technology are you using?? i have some examples with servlets and jsp.
2008/10/28 address-removed ([email]address-removed[/email]) <address-removed ([email]address-removed[/email])>
| Quote: |
How can I populate a combobox with javadb table data and then use the selected item to pupulate the master table? I have tried to bind to the table but the what shows up is the table name. |
--
OJVM
|
|
--
OJVM
|
|
|
| Back to top |
|
 |
kubota2550@gmail.com Posted via mailing list.
|
Posted: Thu Oct 30, 2008 12:54 pm Post subject: JavaDB ComboBox |
|
|
Is there not a way to do automatic binding with a combobox?
On Wed, Oct 29, 2008 at 2:11 PM, lemba <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Hi,
- write method which returns String[] i.e. private String[] getValues()
in this method you make SELECT from your db.
populate ArrayList with your selected values.
convert ArrayList to regular array
- JComboBox cb = new JComboBox( getValues() )
|
|
|
| Back to top |
|
 |
Xavier Callejas Posted via mailing list.
|
Posted: Thu Oct 30, 2008 3:25 pm Post subject: JavaDB ComboBox |
|
|
Omar Vazquez wrote:
| Quote: | | Quote: | How can I populate a combobox with javadb table data and then use the
selected item to pupulate the master table? I have tried to bind to the
table but the what shows up is the table name.
|
|
You could have a event change listener for the combobox, that refresh
(or "re-bind") the SQL query for the data provider of the table every time
it gets changed. |
|
| Back to top |
|
 |
kubota2550@gmail.com Posted via mailing list.
|
Posted: Thu Oct 30, 2008 7:00 pm Post subject: JavaDB ComboBox |
|
|
That's beyond where I am. I'm unable to populate the combobox with the initial data muchless any updated data.
On Thu, Oct 30, 2008 at 11:22 AM, Xavier Callejas <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Omar Vazquez wrote:
| Quote: | | Quote: | How can I populate a combobox with javadb table data and then use the
selected item to pupulate the master table? I have tried to bind to the
table but the what shows up is the table name.
|
|
You could have a event change listener for the combobox, that refresh
(or "re-bind") the SQL query for the data provider of the table every time
it gets changed.
|
|
|
| Back to top |
|
 |
Xavier Callejas Posted via mailing list.
|
Posted: Fri Oct 31, 2008 4:17 am Post subject: JavaDB ComboBox |
|
|
address-removed wrote:
| Quote: | That's beyond where I am. I'm unable to populate the combobox with the
initial data muchless any updated data.
|
If I remember well ... for populating (or binding) a combobox the easiest
way is to drag&drop a table from a database from the service window to the
combobox. |
|
| Back to top |
|
 |
kubota2550@gmail.com Posted via mailing list.
|
Posted: Fri Oct 31, 2008 10:10 am Post subject: JavaDB ComboBox |
|
|
When I drag and drop I get the name of the table listed not the table contents. One place I read that automatic binding works for list boxes but not combo boxes. I'm stumped on how to pupulate this with current database table information.
On Fri, Oct 31, 2008 at 12:17 AM, Xavier Callejas <address-removed ([email]address-removed[/email])> wrote:
| Quote: | address-removed ([email]address-removed[/email]) wrote:
| Quote: | That's beyond where I am. I'm unable to populate the combobox with the
initial data muchless any updated data.
|
If I remember well ... for populating (or binding) a combobox the easiest
way is to drag&drop a table from a database from the service window to the
combobox.
|
|
|
| Back to top |
|
 |
Bill Slack Posted via mailing list.
|
Posted: Fri Oct 31, 2008 4:15 pm Post subject: JavaDB ComboBox |
|
|
Try Patrick Keegan's blogs.
If I recall, he has a three-part tutorial, one of which covers this very thing.
Bill
| Quote: | ----- Original Message -----
From: address-removed ([email]address-removed[/email])
To: address-removed ([email]address-removed[/email])
Sent: Friday, October 31, 2008 3:10 AM
Subject: Re: [nbusers] Re: Re: JavaDB ComboBox
When I drag and drop I get the name of the table listed not the table contents. One place I read that automatic binding works for list boxes but not combo boxes. I'm stumped on how to pupulate this with current database table information.
On Fri, Oct 31, 2008 at 12:17 AM, Xavier Callejas <address-removed ([email]address-removed[/email])> wrote:
| Quote: | address-removed ([email]address-removed[/email]) wrote:
| Quote: | That's beyond where I am. I'm unable to populate the combobox with the
initial data muchless any updated data.
|
If I remember well ... for populating (or binding) a combobox the easiest
way is to drag&drop a table from a database from the service window to the
combobox.
|
|
|
|
| Back to top |
|
 |
Xavier Callejas Posted via mailing list.
|
Posted: Fri Oct 31, 2008 4:51 pm Post subject: JavaDB ComboBox |
|
|
Bill Slack wrote:
| Quote: | When I drag and drop I get the name of the table listed not the table
contents. One place I read that automatic binding works for list boxes
but not combo boxes. I'm stumped on how to pupulate this with current
database table information
|
oh yes, that's true, now I remember.
One easy and fast way to get the content you want in the combobox is to
modify the 'toString()' method of the JPA generated class.
What you see in the contents of the combox (in runtime) after binding is
what the 'toString()' method returns.
For example, you have draged&droped to the combobox a table wich name
is 'Customers', Netbeans automatically creates a Custumers.java that is a
JPA entity class, look for it in your source tree; then open it and look
for the method 'toString()' (I think that is at the end), let us supose
that this table/class has a property named 'NameOfCustomer' then change the
default retuns "..... clasname ..." to 'return this.NameOfCustomer' ...
for example.
Of corse the best would be that the jcombobox work as the list works.
rgds. |
|
| Back to top |
|
 |
|