NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

JavaDB ComboBox

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
kubota2550@gmail.com
Posted via mailing list.





PostPosted: Tue Oct 28, 2008 6:51 pm    Post subject: JavaDB ComboBox Reply with 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.
Back to top
Omar Vazquez
Posted via mailing list.





PostPosted: Wed Oct 29, 2008 3:47 pm    Post subject: JavaDB ComboBox Reply with 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
kubota2550@gmail.com
Posted via mailing list.





PostPosted: Wed Oct 29, 2008 5:02 pm    Post subject: JavaDB ComboBox Reply with 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
Back to top
Omar Vazquez
Posted via mailing list.





PostPosted: Wed Oct 29, 2008 6:02 pm    Post subject: JavaDB ComboBox Reply with 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
lemba



Joined: 03 Oct 2008
Posts: 9

PostPosted: Wed Oct 29, 2008 6:11 pm    Post subject: Reply with 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
kubota2550@gmail.com
Posted via mailing list.





PostPosted: Wed Oct 29, 2008 8:52 pm    Post subject: JavaDB ComboBox Reply with quote

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.





PostPosted: Thu Oct 30, 2008 12:54 pm    Post subject: JavaDB ComboBox Reply with quote

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.





PostPosted: Thu Oct 30, 2008 3:25 pm    Post subject: JavaDB ComboBox Reply with 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
kubota2550@gmail.com
Posted via mailing list.





PostPosted: Thu Oct 30, 2008 7:00 pm    Post subject: JavaDB ComboBox Reply with quote

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.





PostPosted: Fri Oct 31, 2008 4:17 am    Post subject: JavaDB ComboBox Reply with quote

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.





PostPosted: Fri Oct 31, 2008 10:10 am    Post subject: JavaDB ComboBox Reply with 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.

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.





PostPosted: Fri Oct 31, 2008 4:15 pm    Post subject: JavaDB ComboBox Reply with quote

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.





PostPosted: Fri Oct 31, 2008 4:51 pm    Post subject: JavaDB ComboBox Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo