GWT- PopupPanel with search? - java

I am looking for a way to create a popup dialog box when a user double clicks a textinput field that will contain a scroll-able list (from database table) where the user can select a field, hit ok, and have it placed into the textbox when popup closes.
The other major requirement is to have a filter/ or search field in the popup to aid the user in finding the correct option to select from quicker.
What is the best way to implement this?
Modification to gwt's popup panel? maybe a JOptionPane? are there any simple solutions already designed for free commercial use?

You could implement this with a com.google.gwt.user.client.ui.PopupPanel. You can make a PopupPanel that contains a ListBox with your data from the database, along with a OK button. When a user selects a value and hits OK, you should utilize an EventBus along with a custom Event that will pass the value to the field on the page. The page will have an event handler that will catch the event and put it into the field.
Another option is to use a com.google.gwt.user.client.ui.SuggestBox. It is a box that autocompletes / suggests values as you type, kind of like the Youtube search bar.
I can offer more resources to help you accomplish this, if you'd like.

Related

JCheckBoxes inside JComboBox

I have added checkboxes inside combo box in Java. But when I open drop down menu and check one check box, the drop down menu closes. So to select each check box I have to open it every time.
Is there any way so that I can keep the drop down list opened till the time I dont click outside so that I can select any number of check boxes at one time only.
Please help!!
I have added checkboxes inside combo box in Java. But when I open drop
down menu and check one check box, the drop down menu closes. So to
select each check box I have to open it every time. Is there any way
so that I can keep the drop down list opened till the time I dont
click outside so that I can select any number of check boxes at one
time only.
no there isn't, this is default property of (BasicXxx)Popup implemented in Swing API, workaround for series of Bugs in Java1.4_xxx
no_way, only by using dirty hacks, usage of can be Java Version sensitive, or required left mouse button as accelerator
don't do that, another way (and proper of possible ways) is usage of JWindow/undecorated JDialog but required to override ESC Key and Focus lost in Windows three (as you can see in good Java JCalandars/JDatePickers),
I recommend that you to use the Japura API to deal with this, check this link:
http://www.japura.org/checkcombobox
Best Regards :)

Wicket, how to lazy-load DropDown choices on click?

I have a lot of DropDownChoice components with many items in a form, and on loading the form, I'd like to display only the saved selected options. When the user clicks on a DropDownChoice, I'd like to ajax-load the full item list on the fly.
Can this be done?
Add a OnChangeAjaxBehavior to your dropdown-component. Override the onUpdate-method and add another component to the target. The chosen value of the dropdown-component is inside its model.
Update: Okey, I think I know what you're trying to achieve. Add an AjaxFormComponentUpdatingBehavior to your dropdown component with "onclick" as constructor parameter.
Override the onUpdate-method and add your dropdown component to the target. Before you do that, update the dropdown model, so that it now contains all values.
If you have a lot of options to show then using <select> is not the best option.
Better check http://ivaynberg.github.com/select2/ or http://livedocs.dojotoolkit.org/dijit/form/FilteringSelect or any other JS based component which can load options on demand via Ajax.
Maybe you could go with the AjaxEditableLabels... Using the AjaxEditableChoiceLabel from Wicket Extensions, you'll get a compponent that displays the current value as a Label until clicked and the changes to a DropDownChoice via Ajax. That should be pretty much like the solution you're looking for.

AutoCompleteDecorate implemented on JComboBox

For those who are familiar with SwingX's AutoCompleteDecorator, I have a question regarding handling of JComboBox's Popup Visibility. I used AutoCompleteDecorate.decorate(JComboBox combobox) in my current project which I already mentioned in my previous posts, the problem I encountered is when ever the user type a keyword that doesn't match any of the combobox items, the popup remains visible. For the convenience of the users, I would like to hide combobox's popup if the keyword typed doesn't match any of combobox items.
If you want the autocompletion feature, but you don't want to have a popup in the way (especially, as you mention, when entered text doesn't match any item) you might like to try the opensource JIDE Common Layer. It has a very useful (I use it a lot myself) autocompletion feature that you can apply to JComboBoxes, JTextFields, etc..
You can see a Java Web Start overview of the components by clicking on the "RUN IT" link on the above page, or by clicking here. Navigate to
Demos->AutoCompletion Demo->AutoCompletion combo box and text field->AutoCompletion JTextField with a hidden data
to try it out. You can also see the source code by clicking on Browse Source Code.
You can enable/disable a strict flag in order to prevent/allow user to enter text not matched with items.
However, as far as I have tested, JIDE's combo boxes with autocompletion also have the "issue" that keep their popup open even if no match is found, but what I'm suggesting here is to try an autocompleting textfield which has no popup at all (they autocomplete in place, highlighting the part of the matched text that you didn't manually type-in).

Is it possible to disable a JComboBox when a JTextField is edited?

I'm working on a form and I'd like to have a drop-down box where you select a person. It brings up their stored information in the text-fields below, but as soon as you edit one of the text-fields it disables the drop-down box until you save or cancel the changes. The purpose of this is to prevent the user from editing something, thinking it's saved, and then changing to a different person and losing their changes.
Add a DocumentListener to all your text fields. Whenever any data is changed you disable the combo box. When the data is saved you enable the combo box.
See How to Write a DocumentListener for more information and examples.
A better approach might be to popup a JDialog with the data to be changed.
Dynamically disabling combo boxes doesn't seem like a common practice. Perhaps instead you could indicate to the user when something is saved, and if the user attempts to switch people after info has been inputted, you could notify them and ask if they want to continue and lose the data. Is it not possible that some users will enter data, try to use a disabled combo box, and not knowing why it is disabled, they will think you program is broken?

jTextField autocomplete from database

I want a jTextField that shows suggestions in a popup as the user types (like google suggests). I want suggestions data to be fetched from a database table. I have been looking at SwingX and GlazedLists but I think they provide jComboBox autocomplete, and jTextField does not show a popup in these libraries.
I want to monitor user input and re-query the database after specific intervals.
Thanks.
I would keep looking into SwingX or GlazedLists, to avoid re-inventing the wheel. But if you are doing it yourself:
Add a KeyListener to the field and show a popup just below the text field whenever the user types. The popup could just be a menu with possible items or maybe even a JList. Make sure your database query can keep up with the typing or put the work on a separate thread.

Categories

Resources