Turn Select dropdown list not writeable - java

I'm programming a GUI in Java using the Vaadin framework having a question about adjusting the behaviour of a drop down list.
What is the correct property action to make a drop down list of the type Select none-writeable. That is, when selected I don't want the "write-marker" to flash in the list expecting input but rather have the drop down list expand on such an action.
I've tried with searchDropDown.setReadOnly(true); but that turned off the drop down behaviour completely...
Anyone have any ideas...? =)
Thanks!

Try using a NativeSelect instead of ComboBox?

Related

Vaadin GUI Select selectList - setStyle/color of selected item

Hi,
I use Select list in vaadin. How can I change the color of selected item on list ?
As far as I know, there is no direct way of doing it. I've used a Table + CellStyleGenerator to simulate a complex list with multiple colours, but I think than you could use css and alter the default style for the selected item (scroll to 5.15.3 ListSelect) if you struggle a bit.

Best way to implement a selection box from a large number of entries

I have a large set of data from which the user has to select one. I'm thinking of a way to implement it (of course, in a GUI). I have a few ideas. But just thought of posting here as there may be better alternatives..
Say, user has to select a name from a large set of user base. If I simply put a text field for user to enter the name, then there can be issues like entering same name in different formats, misspelling etc...
I see two options here
Using a combo box
Using a list (Actually i'm thinking of something like a tool tip. As I cant show the whole list always due to space issues)
But combo box won't be much user friendly i guess. As the user will have to scroll around the whole list to select an entry. If the number of entries are too large, this will be
Which means, now I'm left only one option. A popping up list, which will change the content according the text user is entering in the text field. So he can type first few letters and the list will show all the entries starting from the entered text. Got my point, right?
Are there any other better to achieve this kind of need?
If I'm going to implement above, what will be the best way to follow. I'm thinking of extending the JTextField to add required functionality. Well, I'll put some method to set the popup list entries. And I'll add some actionListner to watch the text field, and control the popup list accordingly...
Autocomplete is what you are probably looking for. Google for "java swing jcombobox autocomplete" and limit results for the last couple of years to get relevant results. There will be a lot of examples and ideas on how to implement this with custom code.
I believe there is also some custom libraries like "swingx" that provide at least partial or full implementations to save time.
http://swingx.java.net/
They have released code as recently as the beginning of this years so it appears active and might have what you need.
You could take a look at SwingLab's autocomplete feature, it allows you to attach it to a JCombBox, JList or JTextComponent
use AutoComplete JComboBox/JTextField
based on Standard Java Classes
no issue with larger sets of data
no issue with Focus, BackSpace Key, Caret
for better performance to required sort the array before use
simple workaround for setStrict(true/false), restrict input to array

Filtering a ListView in wicket using 2 drop down boxes

I am trying to filter a list that is placed into a listview through the use of 2 drop down boxes.
The first dropdown box is titled price and the second is owner.
I want to be able to select a value in one or more of these drop down boxes and then have the List view re-render with the filtered results.
The trouble is I do not know how to begin this task, would someone be so kind as to enlighten me :D
Thanks in advance!
Your best starting point is probably this example: (Source code also available on this page, ChoicePage.java is the name)
First of all, you have to use a dynamic model in your ListView that generates the list of items depending on what you had selected in the dropdown boxes.
Then the basic idea is that you add an AjaxFormComponentUpdatingBehavior to the components that control the updates (your two dropdown boxes in your case), and in the onUpdate() method of this behaviour you should add the component you want to update to that AjaxRequestTarget passed.

JFace ComboViewer with a header entry?

I'm interested in populating a ComboViewer with a list of objects.
I know JFace has some nice features that support that, but what if I want to make the first entry in the ComboViewer something like
<Select Connection>
or some other dummy entry that doesn't have an object associated to it? Is there any simple generic solution to it?
You could do this with the TableCombo widget from the Nebula project. You can a create TableComboViewer with input, selection listeners etc. but also set the text of the combo independently from the current selection.
TableComboViewer viewer = ...
...
viewer.getTableCombo().setText("...");
I use this in a current project. However the TableCombo is in alpha state, but in my application it works quite fine.
AFAIK you can't do it out of the box. You can write you own LabelProvider to do this, or you may want to switch to something like a ListViewer in a popup window, and use the List's headers to display your special first element.

How to Dynamically adding fields in JSF?

HI All,
I am desperately looking for the assistance on adding and removing the fields and rows using JSF. I am using ICE Faces for the rich UI look. The following is my problem:
I have to add one text box and two buttons (+) and (-) in a row.
When user clicks on the + button, one new row should be added with the above components.
When user clicks on the - button, the corresponding row should be removed from the display.
I am able to add the individual components like text box and remove it. But, here my challenging point is to add and remove as a row. How would I remove that specific row (instance) from the UI View Root.
I have tried several times, but till now I could not find a solution. Please suggest me the possible solutions.
Thanks in advance,
Krishna
Rather use a h:dataTable (or the IceFaces equivalent ice:dataTable) which is backed by a List<Data> contining objects which each represents the data of a single row. On Add just add a new Data item to the list. On Remove just remove the selected Data item from the list.
See also:
How to dynamically add new row to table? - detailed answer to similar question
Using Datatables - shows step by step how to use datatables in JSF 1.x.
CRUD datatable using #ViewScoped - simple example of JSF 2.0 CRUD

Categories