GWT- dynamically make widgets non-editable - java

As per my requirements, I need to make a widget textbox prepopulate based on a selection, then under specific scenerios make the prepopulated field non-editable (from editable) without the page reloading.
The prepopulation works fine, but when I try to change my widget textbox to non-editable from the code (a validator), nothing changes. Of course I can easily make a field editable or noneditable easily on page load by setting my widget attribute directly in sql developer. But I need this to happen on the 'fly'.
So what is the proper strategy?
My thought is the widget is activated on load, and if I change the widget property I need a way to tell it to look there again w/o reloading the entire page?
Any thoughts would be greatly appreciated :)

I think TextBox#setReadOnly should work.

Related

ColumnHideCommand makes the table columns to disappear in NatTable, when all table elements are selected

I have a NatTable component with the following layers:
ViewportLayer
SelectionLayer
RowHideShowLayer
ColumnGroupExpandCollapseLayer
ColumnHideShowLayer
DataLayer
I need to show/hide a specific column, when a checkbox selection changes. In order to that, I use the #doCommand() method provided by the NatTable component:
if(selection) {
nattable.doCommand(new ColumnShowCommand(nattable, COLUMN_INDEX));
} else {
nattable.doCommand(new ColumnHideCommand(nattable, COLUMN_INDEX+1));
}
Everything works just fine, excepting the case when ALL the items in the table are selected, and the ColumnHideCommand is executed. On this specific scenario, the whole table content disappears (Screenshot). If there is no selection in the table, or not all the elements are selected, then everything works just fine.
Please let me know if you have any idea what's going on there or if you experienced this kind of issues before. My experience with NatTables is quite limited, so please let me know if you need any additional information. Thank you!
This is a feature of the SelectionLayer to support multi column hide operations based on the column selection. A ColumnHideCommand get consumed and instead a MultiColumnHideCommand is created and executed based on the fully selected columns. The code in charge is located in SelectionLayer#handleColumnHideCommand(ColumnHideCommand). The method is protected, so if you don't need that feature because you only support column hide/show programmatically and not via UI performed by a user, you can override the method to simply perform a super.doCommand(command); without the check for selections.

GWT- PopupPanel with search?

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.

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.

Adding Focus on SuggestBox?

Hi I want to focus on the SuggestBox as page loads.
I could not find any EventListener for this purpose so I am guessing that I have to
define my own handler to do that (maybe do something with native textbox.focus?)
What is the GWT way to set focus on the text boxes.
Thanks.
I just had to add textBox.setFocus(true).

Make a text field highlighted when tabbed to in NetBeans (Java)

I'm trying to make it so when I tab to some text fields on in my JFrame the data in the text field will be highlighted. I thought I had done this in the properties before but I am not seeing the option now. Does anyone know how to do this?
You could use a FocusListener to work out when your field has focus (tutorial here).
Decide whether you want to select the text in the field, or whether you just want to change the background color. It's not quite clear what you mean by highlight.

Categories

Resources