• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

2 ComboBox's 1 Set

 
Glen Iris
Ranch Hand
Posts: 172
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

I intend having a search where the user can search on two entitys in the database. eg-color and size, shape and sound, height and speed etc. I will provide this functionality through two combo boxs. When the app loads, ComboBox 1's default selection will be color. ComboBox 2's default selection will be size.

So combo box 1 should have all the possible values except the value selected in combobox 2 (color,shape,sound,height,speed)
and combo box 2 should have all the possible values except the value selected in combobox 1 (size,shape,sound,height,speed)

All works great so far!

Next, I add an item listener to combo box 1 saying "if a value is selected in combobox 2, remove that value from combobox 1's set and add the previously selected value of combobox 2, back into combo box 1's set of possible values."

Similarly, I add an item listener to combo box 2 saying "if a value is selected in combobox 1, remove that value from combobox 2's set and add the previously selected value of combobox 1, back into combo box 2's set of possible values."

This works superbly!

Until...

User selects their desired choice in combobox1 (combobox2's values immediatley update). The user then selects their desired choice in combobox2 (combobox1's values immediatley update ).

If you are still reading do you have any ideas?

Thanks,

G
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glen Iris wrote:If you are still reading do you have any ideas?


excellent! Interestingly, I had already stopped reading when I saw this phrase!
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glen Iris wrote:User selects their desired choice in combobox1 (combobox2's values immediatley update). The user then selects their desired choice in combobox2 (combobox1's values immediatley update )


Well champ, isn't it the effect that you wanted? I think I didn't get your problem quite well... the problem is that you wanted the selected option in combo box 1 to stay selected after selecting an option in combo box 2?

Other than that, which assignment is this one? Back in my days, there were no such options... I think I'm getting old
 
Glen Iris
Ranch Hand
Posts: 172
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roberto Perillo wrote:
Glen Iris wrote:User selects their desired choice in combobox1 (combobox2's values immediatley update). The user then selects their desired choice in combobox2 (combobox1's values immediatley update )


the problem is that you wanted the selected option in combo box 1 to stay selected after selecting an option in combo box 2?(


Thats it in a nutshell Roberto. Its the bodgitt and scarper. The user must be able to search on the name, the location or both. I was trying to allow the user to search on any two db parameters. I guess Im over complicating it.

Any ideas on how to allow the user this functionality. I guess radio buttons, or two text fields (one for name, one for location).

G
 
Roel De Nijs
Sheriff
Posts: 9934
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glen Iris wrote:two text fields (one for name, one for location).

That's exactly what I did. One text field for name and another for location. If nothing is entered, all (valid) records are returned. If they fill both, all records with exactly matching name and location are returned. If they fill only one of the text fields, all records with exactly matching name or location are returned. Very easy to implement, easy to use and very intuitive for a user.
 
Glen Iris
Ranch Hand
Posts: 172
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I was trying to be too clever for my own good. Thanks Roel.
 
Roel De Nijs
Sheriff
Posts: 9934
113
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never a good idea Always think KISS when developing an application It saved me already lots of time and many
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic